您的当前位置:首页 >> 建站学院 >> 网站运营

手机打开WEB站,自动跳转到WAP站

来源:无锡做网站  作者:35on  时间:2015/3/6 17:24:48

http://www.seowhy.com/bbs/thread-13282442-1-1.html

手机打开WEB站,自动跳转到WAP站:

解决办法:
在WEB网站加入一段判断的JS即可。


JS代码为:uaredirect.js

function uaredirect(f){try{if(document.getElementById("bdmark")!=null){return}var b=false;if(arguments[1]){var e=window.location.host;var a=window.location.href;if(isSubdomain(arguments[1],e)==1){f=f+"/#m/"+a;b=true}else{if(isSubdomain(arguments[1],e)==2){f=f+"/#m/"+a;b=true}else{f=a;b=false}}}else{b=true}if(b){var c=window.location.hash;if(!c.match("fromapp")){if((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))){location.replace(f)}}}}catch(d){}}function isSubdomain(c,d){this.getdomain=function(f){var e=f.indexOf("://");if(e>0){var h=f.substr(e+3)}else{var h=f}var g=/^www\./;if(g.test(h)){h=h.substr(4)}return h};if(c==d){return 1}else{var c=this.getdomain(c);var b=this.getdomain(d);if(c==b){return 1}else{c=c.replace(".","\\.");var a=new RegExp("\\."+c+"[        DISCUZ_CODE_1        ]quot;);if(b.match(a)){return 2}else{return 0}}}};

网站地图 Copyright©2017-2018 三五在线科技 版权所有 苏ICP备11076999号-2