/** Smart Machine Browser version info: **/var browser={versions:function () {var u = navigator.useragent, app = Navigator.appversio N return {//Mobile terminal browser version information Trident:u.indexof ("Trident") >-1,//ie kernel presto:u.indexof ("Prest O ") >-1,//opera core webkit:u.indexof (" AppleWebKit ") >-1,//Apple, Google kernel Gecko:u.indexof ( "Gecko") >-1 && u.indexof ("khtml") = =-1,//Firefox core mobile:!! U.match (/applewebkit.*mobile.*/) | |!! U.match (/applewebkit/),//Whether for Mobile terminal iOS:!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/),//ios terminal Android:u.indexof ("Android") >-1 | | U.indexof ("Linux") >-1,//android terminal or UC Browser iphone:u.indexof ("IPhone") >-1 | | U.indexof ("Mac") >-1,//whether for iphone or Qqhd browser ipad:u.indexof ("ipad") >-1,//whether IPAD Web App:u.indexof ("Safari") = =-1//whether the Web should be program, no header with bottom}; } (), Language: (Navigator.browserlAnguage | | navigator.language). toLowerCase ()}/** call method: Mobt ()//drop to the bottom of the page where you need to jump **/function mobt () {if (Browser.versions.android | | Browser.versions.iPhone | | Browser.versions.ios) {var tourl= ""; var url=document.location.href; var sarr=url.split ("/");//The URL address by the "/" segment is primarily used to get the page that needs to jump and then stitching if (sarr[3]!=null) {if (Sarr[3].indexof ("work") &G t;-1 | | Sarr[3].indexof ("about") >-1 | | Sarr[3].indexof ("friend") >-1 | | Sarr[3].indexof ("photo") >-1);//Judging these pages is not required to jump, because I added is a template, so to judge. else if (Sarr[3].indexof ("index") ==0) tourl= "m/"; else tourl= "m/" +sarr[3];//stitching to http://www.86y.org/art_detail.aspx?id=583 for example, need to get just art_detail.aspx?id=5 83 parts, so the mobile page is m/art_detail.aspx?id=583. And so on } else Tourl= "m/index.aspx"//home stitching Window.location.href=tourl; }}
------------------------------------the second kind------------------------------------------------------
Computer-side address:Example: (86y.org)
Mobile Address:Example: Directory (86y.org/m) or level two domain name (m.86y.org)
function Mobt () { var suseragent = Navigator.userAgent.toLowerCase (); var tourl= ""; var url=document.location.href; var pcurl= "86y.org"; var moblieurl= "86y.org/m"; if ((Suseragent.match (/(Ipod|iphone os|midp|ucweb|android|windows ce|windows Mobile)/i)) { //pc end to mobile phone-side if ( Url.indexof (Moblieurl) ==-1) { tourl=url.replace (pcurl,moblieurl); Window.location.href=tourl; } } else{ //Mobile end to PC-side if (Url.indexof ("http://styhsoft.eicp.net:4658/test/m/")!=-1) { tourl= Url.replace (Moblieurl,pcurl); Window.location.href=tourl ; }}} MOBT ();
JS Recognition Mobile Access automatically jump to the corresponding page