Nowadays, having an ipad and using internet and different sites on it is became very common. So this time, I'm gonna tell you that how we can detect ipad device. So, here is it:
A quick String.match regular expression test can check for the presence of "iPad" in the user agent string.
The JavaScript
// For use within normal web clients
var isiPad = navigator.userAgent.match(/iPad/i) != null;
// For use within iPad developer UIWebView
var ua = navigator.userAgent;
var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua);
A quick String.match regular expression test can check for the presence of "iPad" in the user agent string.
The PHP
$isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
This time we look for the position of "iPad" in the user agent string.The .htaccess
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]
No comments:
Post a Comment