How to tell if it's an ipad browser, the key is to see if it has an ipad in the User Agent. The IPad uses the Safari Mobile browser, and his user Agent is:
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
JavaScript code
function Is_ipad () {
var ua = Navigator.userAgent.toLowerCase ();
if (Ua.match (/ipad/i) = = "IPad") {
return true;
} else {
return false;
}
}
Therefore, the code to Judge Ipad,iphone,android is:
<script type="text/javascript"> varbForcepc = fGetQuery("dv") == "pc"; functionfBrowserRedirect(){ varsUserAgent = navigator.userAgent.toLowerCase(); varbIsIpad = sUserAgent.match(/ipad/i) == "ipad"; varbIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; varbIsMidp = sUserAgent.match(/midp/i) == "midp"; varbIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; varbIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; varbIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; varbIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if(bIsIpad){ varsUrl = location.href; if(!bForcepc){ window.location.href = "http://ipad.mail.163.com/"; } } if(bIsIphoneOs || bIsAndroid){ varsUrl = location.href; if(!bForcepc){ window.location.href = "http://smart.mail.163.com/"; } } if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){ varsUrl = location.href; if(!bForcepc){ window.location.href = "http://m.mail.163.com/"; } } } functionfGetQuery(name){//获取参数值 varsUrl = window.location.search.substr(1); varr = sUrl.match(new RegExp("(^|&)"+ name + "=([^&]*)(&|$)")); return(r == null? null: unescape(r[2])); } function fShowVerBlock(){ if(bForcepc){ document.getElementById("dv_block").style.display = "block"; } else{ document.getElementById("ad_block").style.display = "block"; } } fBrowserRedirect(); </script> |