Baidu Siteapp under the product of a jump, use is very convenient. You can use this JS to jump to the mobile version, you can also jump to any location you want to jump.
The JS code is as follows:
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)/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) } returnh}; if(c = =d) {return1 } Else{var c= This. GetDomain (c); var b= This. GetDomain (d); if(c = =b) {return1 } Else{C= C.replace (".", "\ \.")); var a=NewREGEXP ("\ \" + C + "$")); if(B.match (a)) {return2 } Else { return0 } } }};
How to use:
Save the above code for Uaredirect.js, the reference to this JS file is best placed under the title of the site, do not put in the last or other parts, this is because it will load uaredirect.js after the jump, This will be done quickly , if you first load other JS or CSS, will load them before jumping, so that the jump speed will be very slow. loading, just a piece of code will be OK .
Reference code:
<script src= "Your JS storage directory/uaredirect.js" type= "Text/javascript" ></script><script type= "Text/javascript ">uaredirect (" http://m.haishiit.com "," http://www.haishiit.com ");</script>
Description:http://m.haishiit.com is a mobile version of the website, http://www.haishiit.com is a computer version of the website.
Baidu Judge Mobile terminal and automatically jump Uaredirect.js code and use examples