判断访问同一个网址,是来自手机还是pc
Document
functionbrowserRedirect() {
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";
varbIsAndroid=sUserAgent.match(/android/i)=="android";
varbIsCE=sUserAgent.match(/windows ce/i)=="windows ce";
varbIsWM=sUserAgent.match(/windows mobile/i)=="windows mobile";
if(!(bIsIpad||bIsIphoneOs||bIsMidp||bIsUc7||bIsUc||bIsAndroid||bIsCE||bIsWM) ){
//window.location.href="http://www.cnblogs.com/stephenykk/p/3364848.html";
//判断是pc访问
}else{
//判断是手机
window.location.href="https://my.oschina.net/docin/blog/200663"
}
}
browserRedirect();
网友评论