国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > PhpCMS > 正文

phpcms自動跳轉到wap手機站的實現(xiàn)方法

2024-09-10 07:17:20
字體:
來源:轉載
供稿:網(wǎng)友
這篇文章主要為大家詳細介紹了phpcms自動跳轉到wap手機站的實現(xiàn)方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下,有需要的朋友可以收藏方便以后借鑒。

前面361源碼已經(jīng)給大家講過《DedeCMS移動端訪問pc網(wǎng)址自動跳轉代碼》和《PC電腦訪問移動端網(wǎng)頁網(wǎng)站自動跳轉到對應PC網(wǎng)站代碼》的方法,相信不少朋友在處理織夢內核程序的站點的時候,都不會有什么太大的問題。那么phpcms V9如何實現(xiàn)自動跳轉到wap手機站的呢?下面361源碼給大家介紹個簡單的方法,但是稍有局限性,不能實現(xiàn)對應頁面跳轉。方法如下:

只需在模板的<head></head>之間添加如下代碼即可

<meta http-equiv="mobile-agent" content="format=xhtml;url=http://m.vevb.com/">

<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="http://m.vevb.com";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

注意

將本文中的“http://m.vevb.com/”替換為你的手機站域名,一定要以“http://”開頭

這樣就能實現(xiàn)移動設備訪問站點的時候跳轉到手機站點了,唯一的缺憾是不能實現(xiàn)對應跳轉。當然,如果在特定的條件下phpcms V9也是能夠實現(xiàn)對應跳轉的,條件就是:只有當catid與typeid相減的結果相同時才可以用。

首頁跳轉

分析:

PC電腦版首頁:www.survivalescaperooms.com

WAP手機版首頁:m.vevb.com

通過JS代碼實現(xiàn)當打開www.survivalescaperooms.com的時候跳轉到m.vevb.com

實現(xiàn)代碼

在<head></head>之間添加如下代碼即可:

<meta http-equiv="mobile-agent" content="format=xhtml;url=http://m.vevb.com/"><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="http://m.vevb.com/";}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集中營站長發(fā)現(xiàn)只需要調出WAP手機版的typeid即可,可是用{$typeid}調不出來,{$catid}雖然可以調出數(shù)據(jù)但是不是想要的,再觀察發(fā)現(xiàn)我的catid-100=typeid,這樣通過php代碼得出了typeid,就可以實現(xiàn)了欄目頁的跳轉

實現(xiàn)代碼:

在<head></head>之間添加如下代碼即可:

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

內容頁跳轉

分析:

在文章頁的跳轉代碼中catid可以用{$catid}調用,id可以用{$id}調用,typeid咱們在欄目頁跳轉時已經(jīng)分析過了可以通過php實現(xiàn)

實現(xiàn)代碼:

在<head></head>之間添加如下代碼即可:

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

溫馨提示:記得將m.vevb.com替換為您移動端的域名哦!!

其實這個方法比較局限,如果你有更好方法可以聯(lián)系361源碼哦,把更好的方法分享給大家。


以上就是phpcms自動跳轉到wap手機站的實現(xiàn)方法的全部內容,希望對大家的學習和解決疑問有所幫助,也希望大家多多支持武林網(wǎng)。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 高尔夫| 海阳市| 麻栗坡县| 辽阳市| 长葛市| 常德市| 安宁市| 中牟县| 凉城县| 轮台县| 白玉县| 宜丰县| 高青县| 通江县| 博兴县| 盐津县| 岚皋县| 巩留县| 九江县| 连平县| 常州市| 苏州市| 阳城县| 溧水县| 股票| 石阡县| 静宁县| 万山特区| 东兰县| 杭锦后旗| 武威市| 正镶白旗| 泗洪县| 浏阳市| 汶川县| 秭归县| 平舆县| 库车县| 望江县| 全州县| 疏附县|