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

首頁 > CMS > 帝國Empire > 正文

帝國cms電腦pc站url跳轉到手機站url的方式

2024-08-28 12:25:14
字體:
來源:轉載
供稿:網友
本文講解一下帝國cms電腦網站跳轉到手機動態網站和手機靜態網站的方法。

方法一:帝國pc站跳轉到手機靜態站

1、假設我們有帝國cms 電腦網站www.cmsyuanma.com,手機網站m.cmsyuanma.com ,手機網站使用帝國cms的多訪問端功能制作,如果不了解帝國cms多訪問端制作手機網站的方法,請參考:http://www.cmsyuanma.com/a/ecms/658.html
現在電腦端和手機端都是生成靜態網站,除了域名不同,靜態連接地址都是相同的,例如:
www.cmsyuanma.com/china/1.html對應 m.cmsyuanma.com/china/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://m.cmsyuanma.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.cmsyuanma.com/">

(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://m.cmsyuanma.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.cmsyuanma.com<?=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://m.cmsyuanma.com[!--titleurl--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.cmsyuanma.com[!--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://m.cmsyuanma.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.cmsyuanma.com/">

(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://m.cmsyuanma.com/e/action/ListInfo/?classid=[!--self.classid--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.cmsyuanma.com/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://m.cmsyuanma.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.cmsyuanma.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">

添加上面代碼后,pc網站就可以跳轉到手機端的對應網頁了。
注意:使用上面代碼時,把代碼中的域名改成你自己的域名就可以了。

 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桐梓县| 内丘县| 鹿邑县| 石家庄市| 班玛县| 建宁县| 哈尔滨市| 车险| 凌海市| 蕉岭县| 民勤县| 绥江县| 渭源县| 莎车县| 长垣县| 仙居县| 时尚| 彝良县| 左云县| 历史| 涟水县| 嘉黎县| 神池县| 鄢陵县| 民勤县| 万山特区| 鹤岗市| 分宜县| 岑溪市| 台江县| 得荣县| 新宁县| 济源市| 琼中| 南川市| 商洛市| 新巴尔虎左旗| 娄底市| 平江县| 东海县| 油尖旺区|