帝国cms做好了手机版和pc版,怎么让他们互联起来吧,比如我们用手机访问pc端的时候 ,怎么自动跳转到手机版呢,方法如下:
第一步:我们新建一个js文件,命名你随便,路径也随便,js代码如下
function browserRedirect(url) {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM){
window.location.replace(url);
}
}
我把js命名为 m.js 放到了根目录下面
然后把下面的代码复制到对应的模板里面
首页跳转:
<script src='https://www.*****.com/m.js' language='javascript'></script>
<script type="text/javascript">
browserRedirect("http://m.*****.com/");
</script>
封面页和列表页跳转:
© 版权声明
THE END
暂无评论内容