帝国cms-pc端url页面跳转到手机端url页面的方法
方法一:帝国pc端页面跳转到手机端页面
1、PC端域名www.zhzx.info 手机端域名m.zhzx.info
现在电脑端和手机端都是生成静态网站,除了域名不同,静态连接地址都是相同的
例如:www.zhzx.info/1/1.html对应 m.zhzx.info/1/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.zhzx.info/”;}}}
catch(err)
{
}</script>
<meta name=”mobile-agent” content=”format=xhtml;url=http://m.zhzx.info/”>
(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.zhzx.info<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>”;}}}
catch(err)
{
}</script>
<meta name=”mobile-agent” content=”format=xhtml;url=http://m.zhzx.info<?=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.zhzx.info[!–titleurl–]”;}}}
catch(err)
{
}</script>
<meta name=”mobile-agent” content=”format=xhtml;url=http://m.zhzx.info[!–titleurl–]”>