最近公司要做一个新项目,所以及时的记录一些东西,方便开发的时候使用:
检测ipad及iphone、ipod,以及jQTouch的库
原文猛击:
http://net.tutsplus.com/tutorials/tools-and-tips/learn-how-to-develop-for-the-iphone/
一.ipad版本
1.ipad用户代理字符串
Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10
2.ipad - javascript
// For use within normal web clients var isiPad = navigator.userAgent.match(/iPad/i) != null; // For use within iPad developer UIWebView // Thanks to Andrew Hedges! 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);
3.ipad - php
$isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');
二.iphone版本
1.iphone - javascript
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf("iphone_redirect=false") == -1) window.location = "http://m.espn.go.com/wireless/?iphone&i=COMR"; }
2.iphone - php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) { header('Location: http://yoursite.com/iphone'); exit(); }
三.检测iPad屏幕方向
<link rel="stylesheet" media="all and (orientation:portrait)"href="portrait.css">
<link rel="stylesheet" media="all and (orientation:landscape)"href="landscape.css">
动画demo:http://ofps.oreilly.com/titles/9780596805784/
seo小技巧:http://sinobloger.org/tag/ipad-web%E5%BC%80%E5%8F%91/