帝国cms电脑端访问自动跳转到手机网站代码教程
推荐使用第二种,手机端不用在另外生成静态页面,非常省事。
方法一:帝国电脑端站跳转到手机静态站
1、假设我们有帝国CMS 电脑网站.yisvip.,手机网站m.yisvip.,手机网站使用帝国CMS的多访问端功能制作.现在电脑端和手机端都是生成静态网站,除了域名不同,静态连接地址都是相同的,例如:
.yisvip./china/1对应 m.yisvip./china/1
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="/";}}}catch(err){}</script><meta name="mobile-agent" content="format=xhtml;url=/">
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="<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}catch(err){}</script><meta name="mobile-agent" content="format=xhtml;url=<?=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="[!--titleurl--]";}}}catch(err){}</script><meta name="mobile-agent" content="format=xhtml;url=[!--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="/";}}}catch(err){}</script><meta name="mobile-agent" content="format=xhtml;url=/">
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="/e/action/ListInfo/?classid=[!--self.classid--]";}}}catch(err){}</script><meta name="mobile-agent" content="format=xhtml;url=/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="/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}catch(err){}</script><meta name="mobile-agent" content="format=xhtml;url=/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">
添加上面代码后,电脑端网站就可以跳转到手机端的对应网页了。
注意:使用上面代码时,把代码中的域名改成你自己的域名就可以了
帝国CMS7.5内核简洁文章资讯自适应手机HTML5综合类模板源码【内页 文章页、列表标题,描述,严格的SEO标题规范,利于SEO】