JS判断客户端类型(ipad,iphone,android)
JS判断客户端类型(ipad,iphone,android)
var bForcepc = fGetQuery("dv") == "pc"; function fBrowserRedirect(){ var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if(bIsIpad){ var sUrl = location.href; if(!bForcepc){ window.location.href = "http://ipad.mail.163.com/"; } } if(bIsIphoneOs || bIsAndroid){ var sUrl = location.href; if(!bForcepc){ window.location.href = "http://smart.mail.163.com/"; } } if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){ var sUrl = location.href; if(!bForcepc){ window.location.href = "http://m.mail.163.com/"; } } } function fGetQuery(name){//获取参数值 var sUrl = window.location.search.substr(1); var r = 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();
如果您觉得本文的内容对您的学习有所帮助,您可以微信:
相关推荐
chsoft 2020-09-17
Mryiyi 2020-08-07
suweierxing 2020-06-02
yangyujun 2019-12-18
ydc0 2020-07-30
好好学习天天 2020-06-12
fanxiaoxuan 2020-06-03
liuxudong00 2020-11-19
章鱼之家 2020-10-29
leitingdulante 2020-10-21
xuegangic 2020-10-17
硬币0 2020-10-15
ZuoYanDeHuangHun 2020-09-18
MatrixHero 2020-08-20
XxZproject 2020-08-10
定格 2020-08-15
yechen00 2020-07-25
孝平 2020-07-18
ntfsformac 2020-06-23