易优CMS在手机端下,访问PC端自动跳转手机网站的代码

2024-08-16

先要区分网站是自适应还是分离式模板,比如:自适应=PC端和手机端共用模板,分离式=PC端和手机端分开模板

以下代码只需在PC端模板里添加,移动端模板不需要添加。

如果是分离式模板,请在网站模板里的</head>之前加上以下代码:

<meta http-equiv="mobile-agent" content="format=xhtml;url={$eyou.field.pageurl_m}">
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/applewebkit.*mobile/i.test(navigator.userAgent.toLowerCase()) || (/midp|symbianos|nokia|samsung|lg|nec|tcl|alcatel|bird|dbtel|dopod|philips|haier|lenovo|mot-|nokia|sonyericsson|sie-|amoi|zte/.test(navigator.userAgent.toLowerCase()))){try{if(/android|windows phone|webos|iphone|ipod|blackberry/i.test(navigator.userAgent.toLowerCase())){window.location.href="{$eyou.field.pageurl_m}";}else if(/ipad/i.test(navigator.userAgent.toLowerCase())){}else{}}catch(e){}}}</script>

如果是响应式自适应模板,而且后台开启并配置了手机端域名,请在网站模板里的</head>之前加上以下代码:
<meta http-equiv="mobile-agent" content="format=xhtml;url={$eyou.field.pageurl_m}">
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/applewebkit.*mobile/i.test(navigator.userAgent.toLowerCase()) || (/midp|symbianos|nokia|samsung|lg|nec|tcl|alcatel|bird|dbtel|dopod|philips|haier|lenovo|mot-|nokia|sonyericsson|sie-|amoi|zte/.test(navigator.userAgent.toLowerCase()))){try{if(/android|windows phone|webos|iphone|ipod|blackberry/i.test(navigator.userAgent.toLowerCase())){if(window.location.toString().indexOf('{$eyou.field.mobile_domain}') == -1){window.location.href="{$eyou.field.pageurl_m}";}}else if(/ipad/i.test(navigator.userAgent.toLowerCase())){}else{}}catch(e){}}}</script>



(图1)




加入收藏 打赏

感谢您的支持,我会继续努力的!

打开微信扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在

1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!
2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理!
3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有积分奖励和额外收入!

首页 > 教程资料 > CMS教程 易优CMS在手机端下,访问PC端自动跳转手机网站的代码 http://gm7878.cn/cmsjiaocheng/63.html

相关文章

评论
加载中~