JS前端开发判断是否是手机端并跳转操作(小结)

  

        & lt;脚本type=" text/javascript祝辞//borwserRedirect   (函数browserRedirect () {   var sUserAgent=navigator.userAgent.toLowerCase ();   var bIsIpad=sUserAgent.match ipad (//i)==癷pad”;   var bIsIphone=sUserAgent。匹配(/iphone os/i)==癷phone操作系统”;   var bIsMidp=sUserAgent.match (/midp/i)==癿idp”;   var bIsUc7=sUserAgent.match (/rv:为1.2.3.4/i)==胺砍?为1.2.3.4”;   var bIsUc=sUserAgent.match (/ucweb/i)==皐eb”;   var bIsCE=sUserAgent。匹配(/windows ce/i)==皐indows ce”;   var bIsWM=sUserAgent。匹配(/windows mobile/i)==' windows mobile ';   var bIsAndroid=sUserAgent.match (/android/i)==癮ndroid”;   如果(bIsIpad | | bIsIphone | | bIsMidp | | bIsUc7 | | bIsUc | | bIsCE | | bIsWM | | bIsAndroid) {   window.location。href=' https://www.yisu.com/zixun/跳转的移动端网址”;   }   })();   & lt;/script>   & lt;脚本type=" text/javascript祝辞   & lt; !//平台,设备和操作系统={var系统   胜利:假的,   麦克:假的,   xll:假的,   ipad:假   };//检测平台   var p=navigator.platform;   系统。赢得=p.indexOf(“赢”)==0;   系统。mac=p.indexOf (mac)==0;   系统。x11=(p==x11) | | (p.indexOf (“Linux”)==0);   系统。ipad=(navigator.userAgent.match ipad (//i) !=null) & # 63;事实:假;//跳转语句,如果是手机访问就自动跳转到wap.baidu.com页面   如果系统。赢得| |系统。mac | | system.xll | | system.ipad) {   其他}{   window.location。href=" http://www.jdpatro.com/3g/";   }   ——比;   & lt;/script>      

        & lt;脚本type=" text/javascript祝辞   如果(window.location.toString () .indexOf(参照=padindex) !=1) {   其他}{   如果(/AppleWebKit。*手机/电脑(navigator.userAgent) | | (/MIDP | SymbianOS诺基亚三星LG | | | | NEC | TCL |阿尔卡特鸟| |迪比特海尔多普达飞利浦| | | | |联想非常贴切——|诺基亚|索爱|您- - - - - - |夏新|中兴/test (navigator.userAgent))) {   如果(window.location.href.indexOf(“& # 63;移动”)& lt; 0) {   尝试{   如果Android (/Windows Phone | | webOS | | iPhone的iPod |黑莓/信息技术(navigator.userAgent)) {   window.location.href=" http://xw.qq.com/index.htm ";   }else if (/iPad/信息技术(navigator.userAgent)) {//window.location.href=" http://www.qq.com/pad/"   其他}{   window.location.href=" http://xw.qq.com/simple/s/index/"   }   }捕捉(e) {}   }   }   }   & lt;/script>   & lt;脚本type=" text/javascript祝辞   & lt; !//平台,设备和操作系统={var系统   胜利:假的,   麦克:假的,   xll:假的,   ipad:假   };//检测平台   var p=navigator.platform;   系统。赢得=p.indexOf(“赢”)==0;   系统。mac=p.indexOf (mac)==0;   系统。x11=(p==x11) | | (p.indexOf (“Linux”)==0);   系统。ipad=(navigator.userAgent.match ipad (//i) !=null) & # 63;事实:假;//跳转语句,如果是手机访问就自动跳转到wap.baidu.com页面   如果系统。赢得| |系统。mac | | system.xll | | system.ipad) {   其他}{   window.location。href=" http://www.jdpatro.com/3g/";   }   ——比;   & lt;/script>      

        & lt;脚本type=" text/javascript祝辞   var bForcepc=fGetQuery (dv)==皃c”;   函数fBrowserRedirect () {   var sUserAgent=navigator.userAgent.toLowerCase ();   var bIsIpad=sUserAgent.match (/ipad/i)==癷pad”;   var bIsIphoneOs=sUserAgent。匹配(/iphone os/i)==癷phone操作系统”;   var bIsMidp=sUserAgent.match (/midp/i)==癿idp”;   var bIsUc7=sUserAgent.match (/rv:为1.2.3.4/i)==胺砍?为1.2.3.4”;   var bIsUc=sUserAgent.match (/ucweb/i)==皍cweb”;   var bIsAndroid=sUserAgent.match (/android/i)==癮ndroid”;   var bIsCE=sUserAgent。匹配(/windows ce/i)==皐indows ce”;   var bIsWM=sUserAgent。匹配(/windows mobile/i)==皐indows mobile”;   如果(bIsIpad) {   var sUrl=location.href;   如果(! bForcepc) {   window.location。href=" http://ipad.mail.163.com/";   }   }   如果(bIsIphoneOs | | bIsAndroid) {   var sUrl=location.href;   如果(! bForcepc) {   window.location。href=" http://smart.mail.163.com/";   }   }   如果(bIsMidp | | bIsUc7 | | bIsUc | | bIsCE | | bIsWM) {   var sUrl=location.href;   如果(! bForcepc) {   window.location。href=" http://m.mail.163.com/";   }   }   }   函数fGetQuery(名字){//获取参数的值   var sUrl=window.location.search.substr (1);   var r=sUrl。(新RegExp匹配(“(^ |,)”+名字+”=((^和)*)(和| $)));   返回(r==null & # 63;空:(r [2]));   }   函数fShowVerBlock () {   如果(bForcepc) {   document.getElementByIdx_x .style (“dv_block”)。显示=翱椤?   }   其他{   document.getElementByIdx_x .style (“ad_block”)。显示=翱椤?   }   }   fBrowserRedirect ();   & lt;/script>

JS前端开发判断是否是手机端并跳转操作(小结)