Function ismobilephone () {function getcookie (sName) {var sCookies = document.cookie ;if ("string" == typeof (sName)) {var sRE = "(?:; )?" +sname+ "= ([^;] *);?" ;var rere = new regexp (SRE) ;if (Rere.test (scookies)) {return decodeURIComponent (regexp["$"]) ;} else {return null ;}} else {return scookies ;}} var pcpagetip = ' You are going to jump to the computer version of the webpage, will use more mobile Internet traffic, whether continue? ';var curl = window.location.href;var referrer = document.referrer;var mindex = ' http://m.a.com/?v=1 '; var mflag = window.location.hash, pcmflag = getcookie (' PCM ');/*if (mflag == ' #m ') {if (confirm (Pcpagetip)) {return;}} */ var useragent = navigator.useragent; if (userAgent) {useragent = useragent.touppercase (), if (Useragent.indexof ("PAD") >-1) { return; }var mobilephonelist = ["IOS", "IPHONE", " ANDROID "," Windows phone "];for (var i=0,len=mobilephonelist.length;i<len;i++) {if (UserAgent.indexOf ( Mobilephonelist[i]) (>-1) {function ispcpage (URL) {var pcdomains = [' sale.a.com ', ' pinpaijie.a.com '];for (var i = 0, len = pcdomains.length; i < len; i++) {if (Url.indexof (pcdomains[i]) != -1) return true ;} Return false;} var murl = curl.replace (/sale\.a\.com\/act/, ' M.a.com/sale/act ');// no sale m & mcif (Ispcpage (murl) | | mFlag == ' #m ' | | pcmFlag == ' 1 ') {if (confirm (Pcpagetip)) {return;} else {if (referrer && referrer != ") {if (referrer === curl) {window.location.href = mindex;return;} else {window.location.href = referrer;return;}} else {window.location.href = mindex;return;}}} M pageif (Murl.indexof (' m.a.com ') != -1) {window.location.href = Murl;return;} } } } } ismobilephone ();
This article is from the "wind Blowing Snow Fall" blog, please be sure to keep this source http://cbsizhang.blog.51cto.com/7436956/1595805
JS to determine whether from the mobile phone and jump to the mobile version