Nov 22 2010

ipad iphone ipod erkennen

The JavaScript
Copy this code to the clipboard
1
var isiPad = navigator.userAgent.match(/iPad/i) != null;
A quick String.match regular expression test can check for the presence of “iPad” in the user agent string.

The PHP
Copy this code to the clipboard
1
$isiPad = (bool) strpos($_SERVER[‘HTTP_USER_AGENT’],’iPad’);
This time we look for the position of “iPad” in the user agent string.

The .htaccess
Copy this code to the clipboard
1
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
2
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]