亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - How to load different html on the JD homepage on the PC and mobile terminals?
女神的閨蜜愛上我
女神的閨蜜愛上我 2017-06-17 09:16:32
0
5
1109

Using a mobile browser to access JD.com’s domain name is http://m.jd.com
Using a computer to access JD.com is http://www.jd.com. Of course, the two pages are different. What’s wrong with this? Realized?
Write an example code if it is convenient, thank you!

女神的閨蜜愛上我
女神的閨蜜愛上我

reply all(5)
劉奇

After entering www.jd.com, if the code determines that it is a mobile phone, it will jump to m.jd.com

let ua = window.navigator.userAgent.toLocaleLowerCase()
let murl ="http://m.jd.com",
let reg =/iphone|android|symbianos|windows\sphone/g

if (reg .test(ua )) {
    window.location.href = murl 
}

JD source code:

!function(n){function o(n){for(var o=n+"=",t=document.cookie.split(";"),e=0;e<t.length;e++){for(var i=t[e];" "==i.charAt(0);)i=i.substring(1,i.length);if(0==i.indexOf(o))return i.substring(o.length,i.length)}return null}var t=o("pcm"),e=n.navigator.userAgent.toLocaleLowerCase(),i="http://m.jd.com",r=/iphone|android|symbianos|windows\sphone/g,c=/micromessenger|qq\/[\d.]+/i;return c.test(e)?(n.location.!=t?(n.location.href=i,!1):void 0}(window);
阿神

Just judgeUA

左手右手慢動(dòng)作

request.getHeader("user-agent")

淡淡煙草味

userAgent

Peter_Zhu

window.navigator.userAgent

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template