判斷訪問同一個網(wǎng)址,是來自手機(jī)還是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.
}
}
browserRedirect();