最近公司要做一個新項目,所以及時的記錄一些東西,方便開發的時候使用:
檢測ipad及iphone、ipod,以及jQTouch的庫
原文猛擊:
http://davidwalsh.name
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/
開發:https://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/Introduction/Introduction.html
seo小技巧:http://sinobloger.org/tag/ipad-web%E5%BC%80%E5%8F%91/