幻灯二

PHPCMS V9 PC电脑版跳转到WAP手机版对应页面的方法

本文主要讲解PHPCMS V9 PC电脑版跳转到WAP手机版对应页面的方法,不过此方法有局限性,只有当catid与typeid相减的结果相同时才可以用,如果您有更好的方法请加群教下大家,谢谢!QQ群:292800309
在这篇文章之前CMS集中营站长发布过一篇文章关于跳转到wap手机站的实现方法,那篇文章不论在电脑版的哪个页面都会跳转到wap手机站的首页,可是如果在百度里搜出来的结果是PC电脑版的内页,那么当用户点击后仍旧调转到WAP手机版首页,那样用户可能因为没有找到自己要的内容而离开了。CMS集中营站长绞尽脑汁的想出了一个方法,现以CMS集中营站长的美女图片站咪喜哥精点为例总结如下:

首页跳转:
分析:
咪喜哥精点PC电脑版首页:
咪喜哥精点WAP手机版首页:m.mxgjd.com
通过JS代码实现当打开的时候跳转到m.mxgjd.com
实现代码:
在<head></head>之间添加如下代码即可:
<meta http-equiv="mobile-agent" content="format=xhtml;url=">
<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="
";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

栏目页跳转:
分析:以前3个栏目为例分析
咪喜哥精点PC电脑版栏目ID:性感美女--catid=101 丝袜美腿--catid=102 清纯气质--catid=103
咪喜哥精点WAP手机版栏目ID:性感美女--typeid=1 丝袜美腿--typeid=2 清纯气质--typeid=3
通过观察WAP手机版栏目页链接CMS集中营站长发现只需要调出WAP手机版的typeid即可,可是用{$typeid}调不出来,{$catid}虽然可以调出数据但是不是想要的,再观察发现我的catid-100=typeid,这样通过php代码得出了typeid,就可以实现了栏目页的跳转
实现代码:
在<head></head>之间添加如下代码即可:
<?php $a = $catid; ?>
<?php $b = $a-100; ?>

<meta http-equiv="mobile-agent" content="format=xhtml;url=">
<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="
?&a=lists&typeid=<?php echo $b; ?>";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

内容页跳转:
分析:
在文章页的跳转代码中catid可以用{$catid}调用,id可以用{$id}调用,typeid咱们在栏目页跳转时已经分析过了可以通过php实现
实现代码:
在<head></head>之间添加如下代码即可:
<?php $a = $catid; ?>
<?php $b = $a-100; ?>

<meta http-equiv="mobile-agent" content="format=xhtml;url=">
<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="
?&a=show&catid={$catid}&typeid=<?php echo $b; ?>&id={$id}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

温馨提示:记得将m.mxgjd.com替换为您移动端的域名哦!!!

您可能还会对下面的文章感兴趣:

内容页广告位一