一叶知秋 提供的 :帝国cms电脑pc站url跳转到手机站url的方法 外网介绍信息,仅供参考

作者 : 会员:虎哥 更新时间: 2020-06-03 共529人阅读 投诉/版权异议
本文讲解一下帝国cms电脑网站跳转到手机动态网站和手机静态网站的方法。方法一:帝国pc站跳转到手机静态站1、假设我们有帝国cms 电脑网站www.lcqez.com,手机网站m.lcqez.com,手机网站使用帝国cms的多访问端功能

本文讲解一下帝国cms电脑网站跳转到手机动态网站和手机静态网站的方法。

方法一:帝国pc站跳转到手机静态站

1、假设我们有帝国cms 电脑网站www.lcqez.com,手机网站m.lcqez.com,手机网站使用帝国cms的多访问端功能制作.现在电脑端和手机端都是生成静态网站,除了域名不同,静态连接地址都是相同的,例如:
www.lcqez.com/china/1.html对应 m.lcqez.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.lcqez.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.lcqez.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.lcqez.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.lcqez.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.lcqez.com[!--titleurl--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.lcqez.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.lcqez.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.lcqez.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.lcqez.com/e/action/ListInfo/?classid=[!--self.classid--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.lcqez.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.lcqez.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.lcqez.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">

添加上面代码后,pc网站就可以跳转到手机端的对应网页了。
注意:使用上面代码时,把代码中的域名改成你自己的域名就可以了。

SVIP免费 终身SVIP免费
柳林园资源网 本站不存储任何资源文件,敬请周知!
柳林园资源网 » 帝国cms电脑pc站url跳转到手机站url的方法
标签:
【不是 柳林园 客服】 全平台技术咨询 QQ:786101282 | 视觉设计咨询 QQ:1976669278

常见问题FAQ

源码资源都是完整的可运营的吗?
本站不存储任何资源文件,敬请周知!柳林园资源分享目的是学习研究使用,资源由会员分享及编辑人员整理后发布,请勿商用!
再次申明一下,站点所有数据仅供会员学习、参考、研究使用,不得商用!如果你对资源感觉比较满意,建议您购买正版程序或者最新的教程,以便获取更好的技术支持。
你们提供技术支持吗?
柳林园目前资源众多,如果您有项目外包二开需求,请联系客服。我们不对特定资源提供技术支持。如有技术需求请加QQ群与网友互动交流
想购买你们的终身会员,如果你们后期关站了怎么办?
感谢您的关注,目前liulinyuan域名注册已经超过10年并且我们有自己的项目技术团队,柳林园站点只是方便项目技术查阅资料使用,对外没有盈利需求。目前至可预见的未来一段时间,我们没有关站的可能。如果出现政策或者其他原因导致liulinyuan无法正常运行,我们承诺,凡事在有效期内的终身会员及年会员都会收到一份完整的站点数据!

2 评论

发表评论