进入www.jd.com后代码判断是手机的话就跳转m.jd.com
let ua = window.navigator.userAgent.toLocaleLowerCase()
let murl ="//m.jd.com"
let reg =/iphone|android|symbianos|windowssphone/g
if (reg .test(ua )) {
window.location.href = murl
}
京东源码:
!function(n){function o(n){for(var o=n+"=",t=document.cookie.split(";"),e=0;e<t.length;e++){for(vari=t[e];" "==i.charAt(0);)i=i.substring(1,i.length);if(0==i.indexOf(o))returni.substring(o.length,i.length)}return null}vart=o("pcm"),e=n.navigator.userAgent.toLocaleLowerCase(),i="//m.jd.com",r=/iphone|android|symbianos|windowssphone/g,c=/micromessenger|qq/[d.]+/i;return c.test(e)?(n.location.href="//wqs.jd.com/?from=jdindex",!1):r.test(e)&&"1"!=t?(n.location.href=i,!1):void 0}(window);