首页 > 移动平台 > 详细

京东首页如何实现pc端和移动端加载不同的html的?

时间:2017-10-31 12:00:34      阅读:602      评论:0      收藏:0      [点我收藏+]

进入www.jd.com后代码判断是手机的话就跳转m.jd.com

let ua = window.navigator.userAgent.toLocaleLowerCase()
let murl ="//m.jd.com"
let reg =/iphone|android|symbianos|windows\sphone/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|windows\sphone/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);

京东首页如何实现pc端和移动端加载不同的html的?

原文:http://www.cnblogs.com/ifworld/p/7760739.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!