我要投稿
投诉建议
首页
传统文化
武术天地
编程技术
好听音乐
养生中医
智慧人生
常用工具
写作园地
影视娱乐
php专栏
道德经专栏
您当前的位置:
首页
>
编程技术
帝国cms电脑pc站url跳转到手机站url的方法
时间:2021-07-27 10:10:09 来源:网络 编辑:本站 点击:
本文讲解一下帝国cms电脑网站跳转到手机动态网站和手机静态网站的方法。
方法一:帝国pc站跳转到手机静态站
1、假设我们有帝国cms 电脑网站
www.zzarea.com
,手机网站m.zzarea.com,手机网站使用帝国cms的多访问端功能制作.现在电脑端和手机端都是生成静态网站,除了域名不同,静态连接地址都是相同的,例如:
www.zzarea.com/china/1.html对应 m.zzarea.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.zzarea.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.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.zzarea.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.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.zzarea.com[!--titleurl--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.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.zzarea.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.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.zzarea.com/e/action/ListInfo/?classid=[!--self.classid--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.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.zzarea.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">
添加上面代码后,pc网站就可以跳转到手机端的对应网页了。
注意:使用上面代码时,把代码中的域名改成你自己的域名就可以了。
点赞
返回
发表评论
共有
条评论
用户名:
密码:
验证码:
匿名发表
栏目导航
●
|
传统文化
|
武术天地
|
编程技术
|
好听音乐
|
养生中医
|
智慧人生
|
常用工具
|
写作园地
|
影视娱乐
|
php专栏
|
道德经专栏
|
最新推荐
python内建函数大…
点击按钮(button)…
帝国cms网络视频引…
相关文章
栏目更新
栏目热门
友情链接
帝国CMS
b站视频解析
哔哩哔哩
5sing音乐
劝学网
易文言
php中文网
喜马拉雅
引用视频
代码段生成
道医书库
墨鱼部落格
妍婷姝专辑
中华武术
周易全文
星座123
好看视频
汉程测试
桃花仙人
b站解析(91666)
菜鸟教程
小甲鱼学习计划
太极剑视频
零基础学Python
零基础学Web
零基础学汇编
数据结构和算法
网易云课堂
小甲鱼答案
Python 标准库
360图书馆
天涯知识库
emmet
传智播客
21世纪视频
超星视频
我爱自学网
51cto学院
极客学院
外唐教程网
CSDN
千字文
小不点
emmet文档
emmet手册
HTML中文网
U钙网LOGO
w3cschool
博客园
找盘网
前沿视频
百度技术
百度智能
腾讯课堂
慕课网
邢帅教育
网易公开课
大学生自学网
千锋教育视频
教程之家
北风网
渡一教育腾讯课堂
渡一教育
小甲鱼python新视频
鱼C工作室
小甲鱼系列视频
摄图网
爱拍剪辑
爱剪辑
傲软压缩宝
Arctime字幕软件
字幕在线转换器
喜马拉雅音频提取
U盘安装盘制作
我爱卡
汉字五行
五行查询
卜易居
片库网
学堂在线
易通cms
太极拳师师
中医世家
抖音视频解析
快手视频解析
微博视频解析
斗鱼视频解析
虎牙视频解析
左岸抖音歌曲
北京深度矩阵网络
海南息垚
北京深度矩阵
腾牛网
96开发网
创金游戏库
逗游
逗游网
007游戏网
逗游红包游戏
TapTap
网站首页
|
关于我们
|
服务条款
|
广告服务
|
联系我们
|
网站地图
|
免责声明
|
代码运行
|
手机版
声明:本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
Powered by
家园网www.jy.wang
© 2021-2029