When users visit your site, if it is PC-side access, then do not do, if it is mobile phone or tablet access, jump to their own definition of the mobile phone page, this is often used when doing webapp, the code to share to everyone, I hope to help you.
First, you have to refer to a JSUAREDIRECT.JS,JS source in the page as follows:
functionUaredirect (f) {Try{if(document.getElementById ("Bdmark")! =NULL){return}varb=false;if(Arguments[1]) {varE=window.location.host;varA=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) {varC=window.location.hash;if(!c.match ("Fromapp")) {if((Navigator.userAgent.match (/(iphone|ipod| Android|ios))) {Location.replace (f)}}}}Catch(d) {}}functionIssubdomain (c,d) { This. getdomain=function(f) {varE=f.indexof ("://");if(e>0) {varH=f.substr (E+3)}Else{varH=F}varg=/^www\./;if(G.test (h)) {H=H.SUBSTR (4)}returnh};if(C==d) {return1}Else{varC= This. GetDomain (c);varb= This. GetDomain (d);if(c==b) {return1}Else{C=c.replace (".", "\ \.");varA=NewREGEXP ("\ \") +c+ "$");if(B.match (a)) {return2}Else{return0}}};
View Code
Then call:
<script type= "Text/javascript" >uaredirect ("http://www.weixh.net/wap/", "http://www.weixh.net"); </script >
The previous parameter for the mobile phone page, the following parameters for your site's domain name, you need to pay attention to: Put the two JS to the head of the page, can not let the mobile phone users see the content of the computer page and then jump, this effect is poor.
Yi Read the net to use this, but the phone page directly with Baidu WebApp generated, the effect is not very good, we can go to see www.eadu123.com
JS Judge Mobile Access page, according to mobile phone access or PC access jump