方法一:帝國pc站跳轉到手機靜態站
接下來要給電腦網站的首頁、列表頁、內容頁的模板添加跳轉代碼,方法如下:
js是瀏覽器跳轉,meta是告訴搜索引擎移動頁面的地址。
(1)首頁模板需添加下面代碼
- <script type="text/javascript">
- try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
- {if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
- {window.location="http://你的手機訪問域名/";}}}
- catch(err)
- {
- }</script>
- <meta name="mobile-agent" content="format=xhtml;url=http://你的手機訪問域名/">
(2)封面頁和列表頁添加下面代碼
- <script type="text/javascript">
- try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
- {if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
- {window.location="http://你的手機訪問域名<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
- catch(err)
- {
- }</script>
- <meta name="mobile-agent" content="format=xhtml;url=http://你的手機訪問域名<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>">
(3)內容頁添加下面代碼
- <script type="text/javascript">
- try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
- {if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
- {window.location="http://你的手機訪問域名[!--titleurl--]";}}}
- catch(err)
- {
- }</script>
- <meta name="mobile-agent" content="format=xhtml;url=http://你的手機訪問域名[!--titleurl--]">
添加完上面代碼后,帝國cms的電腦網站的每個頁面都可以跳轉到手機靜態網站了。
但手機靜態站是有缺點的,每次我們更新電腦端文章,都要去手機端后臺重新生成一下html,比較麻煩,所以我們可以把手機站設置成動態訪問,接下來就講解一下電腦端跳轉手機動態站的方法。
方法二:帝國cms電腦網站跳轉到手機動態站的方法
1、首先在電腦端的多訪問端設置,把手機端設置成強制動態頁面模式。這樣手機站就是動態了,不用每次都去生成html 。
2、接下來就是給電腦端模板的首頁、列表頁、內容頁添加相依跳轉代碼,和方法一類似。
js是瀏覽器跳轉,meta是告訴搜索引擎移動頁面的地址。
(1)首頁模板需添加下面代碼
- <script type="text/javascript">
- try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
- {if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
- {window.location="http://你的手機端訪問域名/";}}}
- catch(err)
- {
- }</script>
- <meta name="mobile-agent" content="format=xhtml;url=http://你的手機端訪問域名/">
(2)封面頁和列表頁添加下面代碼
- <script type="text/javascript">
- try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
- {if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
- {window.location="http://你的手機端訪問域名/e/action/ListInfo/?classid=[!--self.classid--]";}}}
- catch(err)
- {
- }</script>
- <meta name="mobile-agent" content="format=xhtml;url=http://你的手機端訪問域名/e/action/ListInfo/?classid=[!--self.classid--]">
(3)內容頁添加下面代碼
- <script type="text/javascript">
- try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
- {if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
- {window.location="http://你的手機端訪問域名/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}
- catch(err)
- {
- }</script>
- <meta name="mobile-agent" content="format=xhtml;url=http://你的手機端訪問域名/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">
添加上面代碼后,pc網站就可以跳轉到手機端的對應網頁了。