织梦网站手机端访问PC端页面跳转至对应的手机站页面,同样也是需要添加三处代码,分别是在首页、内容页、以及列表页。以下代码经本站亲自测试,可正常运行。 首页跳转代……
织梦网站手机端访问PC端页面跳转至对应的手机站页面,同样也是需要添加三处代码,分别是在首页、内容页、以及列表页。以下代码经本站亲自测试,可正常运行。
首页跳转代码:
<script type="text/javascript">
if(window.location.toString().indexOf('pref=padindex') != -1){
}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent)
|| (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|
DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-
|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent)))
{if(window.location.href.indexOf("?mobile")<0){
try{if(/Android|Windows Phone|webOS|iPhone|iPod
|BlackBerry/i.test(navigator.userAgent))
{window.location.href="{dede:global.cfg_wap/}/index.php";}
else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}
</script>
内容页跳转代码:
<script type="text/javascript">
if(window.location.toString().indexOf('pref=padindex') != -1){
}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent)
|| (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|
BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|
Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent)))
{if(window.location.href.indexOf("?mobile")<0)
{try{if(/Android|Windows Phone|webOS|iPhone|iPod|
BlackBerry/i.test(navigator.userAgent))
{window.location.href="{dede:global.cfg_wap/}/view.php?aid={dede:field.id/}";}
else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}
</script>
列表页跳转代码:
<script type="text/javascript">
if(window.location.toString().indexOf('pref=padindex') != -1){
}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent)
|| (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|
BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|
Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent)))
{if(window.location.href.indexOf("?mobile")<0)
{try{if(/Android|Windows Phone|webOS|iPhone|iPod|
BlackBerry/i.test(navigator.userAgent))
{window.location.href="{dede:global.cfg_wap/}/list.php?tid={dede:field.id/}";}
else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}
</script>
其中{dede:global.cfg_wap}为手机端的域名。

还没有评论呢,快来抢沙发~