账号通
    

账号  

密码  

2355

查看

2

回复
主题:[讨论]网站生成静态页面之后手机访问html页面如何自动跳转到手机端? [收藏主题]  
网络情缘js323 当前离线

140

主题

3

广播

3

粉丝
添加关注
级别:一年级

用户积分:426 分
登录次数:55 次
注册时间:2013/6/10
最后登录:2018/2/9
网络情缘js323 发表于:2016/11/12 18:48:54   | 显示全部帖子 查看该作者主题 楼主 
做在线知识付费 选科汛云开店

在网页模板的<head>与</head>之间加入以下代码就可以实现手机访问电脑的静态网页跳转到手机站的相应页面



1:内容页代码

<script type="text/javascript">

if(/Android|webOS|iPhone|iPod|BlackBerry|Windows CE|Windows Phone/i.test(navigator.userAgent)){

if(window.location.href.indexOf("?pc")<0){try{window.location.href="/3g/Show.asp?m={$ChannelID}&d={$InfoID}"}catch(e){}}

}

</script>



2:栏目页代杩

<script type="text/javascript">

if(/Android|webOS|iPhone|iPod|BlackBerry|Windows CE|Windows Phone/i.test(navigator.userAgent)){

if(window.location.href.indexOf("?pc")<0){try{window.location.href="/3g/list.asp?id={$GetSmallClassID}"}catch(e){}}

}

</script>



3:网站首页代码

<script type="text/javascript">

if(/Android|webOS|iPhone|iPod|BlackBerry|Windows CE|Windows Phone/i.test(navigator.userAgent)){

if(window.location.href.indexOf("?pc")<0){try{window.location.href="/"}catch(e){}}

}

</script>



 
  支持(0) | 反对(0) 回到顶部顶端 回到底部底部
<上一主题 | 下一主题 >
Powered By KesionCMS Version X1
厦门科汛软件有限公司 © 2006-2016 页面执行4.43945秒 powered by KesionCMS 9.0