專注互聯網綜合服務解決方案
探索互聯網行業前沿資訊
及時獲取較新優惠信息
當前位置:首頁 »帝國cms跳轉到手機的解決方法
本文講解一下帝國cms電腦網站跳轉到手機動態網站和手機靜態網站的方法。
方法一:帝國pc站跳轉到手機靜態站
1、假設我們有帝國cms 電腦網站www.vipjiandan.com ,手機網站m.erenqiu.cn ,手機網站使用帝國cms的多訪問端功能制作,如果不了解帝國cms多訪問端制作手機網站的方法,請參考:http://www.vipjiandan.com/a/ecms/658.html
現在電腦端和手機端都是生成靜態網站,除了域名不同,靜態連接地址都是相同的,例如:http://www.vipjiandan.com/wen/seonews/668.html 對應 https://m.erenqiu.cn/wen/seonews/668.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="https://m.erenqiu.cn/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.erenqiu.cn/">
(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="https://m.erenqiu.cn<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.erenqiu.cn<?=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="https://m.erenqiu.cn[!--titleurl--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.erenqiu.cn[!--titleurl--]">
添加完上面代碼后,帝國cms的電腦網站的每個頁面都可以跳轉到手機靜態網站了。
但手機靜態站是有缺點的,每一次我們在電腦端更新了文章,需要到手機端后臺再生成一次html,比較麻煩,所以我們可以把手機站設置成動態訪問,下面就說一下帝國cms電腦網站跳轉到手機動態站的方法。
方法二:帝國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="https://m.erenqiu.cn/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.erenqiu.cn/">
(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="https://m.erenqiu.cn/e/action/ListInfo/?classid=[!--self.classid--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.erenqiu.cn/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="https://m.erenqiu.cn/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=https://m.erenqiu.cn/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">
演示百度搜索 www.vipjiandan.com 然后看一下內容頁面就可以了 效果很好
添加上面代碼后,pc網站就可以跳轉到手機端的對應網頁了。
注意:使用上面代碼時,把代碼中的域名改成你自己的域名就可以了。
專注互聯網綜合服務解決方案
探索互聯網行業前沿資訊
及時獲取較新優惠信息
即刻關注 共享精彩
掃一掃
讓我們做得更好!
微信ID:erenqiu
www.vipjiandan.com
任丘市慧科云電子商務有限公司 Copyright www.vipjiandan.com All rights reserved.
Email:erenqiu@sina.com 郵政編碼:062550 冀ICP備15000884號-2
聯系地址:創新大廈A座1316-4室 客服熱線:0317-2391333,15028669339
任丘網站建設、網站設計制作公司-科慧電子商務,已為任丘眾多企業提供網站建設,網站制作,響應式網站設計,手機網站建設,虛擬主機,云主機,服務器租用等建站解決方案。