当前位置: 首页 > 帝国cms > 正文

帝国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–]”>

本文固定链接: https://www.zhzx.info/archives/602 | 赵泽鑫'S Blog

该日志由 zhzx3638 于2018年09月06日发表在 帝国cms 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: 帝国cms-pc端url页面跳转到手机端url页面的方法 | 赵泽鑫'S Blog

帝国cms-pc端url页面跳转到手机端url页面的方法:等您坐沙发呢!

发表评论

您必须 [ 登录 ] 才能发表留言!