不知道我开发的模版哪里出现了问题手机访问偶尔无法自动跳转到手

迅睿框架 更新 2020-12-24 11:17:10 sunbingchen

不知道我开发的模版哪里出现了问题,http://www.tyjs158.com/手机访问偶尔无法自动跳转到手机端http://m.tyjs158.com/微信截图_20191211203650.png


不知道是不是因为我使用了加速乐 缓存 的问题

方案

  • 迅睿框架创始人 #1 · 2019-12-11 20:39:12
    静态是不能跳转的,要加js识别代码,手册有
  • sunbingchen #2 · 2019-12-11 20:54:54
    回复迅睿框架创始人 我按照https://www.xunruicms.com/doc/664.html这个操作,不知道哪里出问题了 报错 syntax error, unexpected '$my_web_url' (T_VARIABLE), expecting ')'
  • 125762285 #3 · 2019-12-11 21:19:39
    可以在静态页面引入或者加入一个js,由js判断跳转
  • 唉呦喂 #4 · 2019-12-11 23:39:58
    <script type="text/javascript">    
    var siteurl = 'https://m.yourdomain.com';    
    // 跳桌面版    
    if (!(navigator.userAgent.match(/(iPhone|iPod|Android|Windows Phone)/i))) {    
    var url=window.location.href;    
    // url=url.replace('http://m.','http://www.');    
    url=url.replace('https://m.','https://www.');    
    location.replace(url);    
    }    
    </script>    
    
    上面代码是在手机模板head内加入
    <script type="text/javascript">
                var new_url = window.location.href;
                if(new_url.indexOf('http://yourdomain') >= 0 || new_url.indexOf('https://yourdomain') >= 0) {
                    new_url = new_url.replace('http://yourdomain', 'http://www.yourdomain');
                    new_url = new_url.replace('https://yourdomain', 'http://www.yourdomain');
                    window.location.replace(new_url);
                }
                var siteurl = 'http://www.iyourdomain.net/';
            </script>
                    <script type="text/javascript">
                <!--跳m站-->
                function getCookie(nm) {
                    var arr, reg = new RegExp("(^| )" + nm + "=([^;]*)(;|$)");
                    if (arr = document.cookie.match(reg)) {
                        return unescape(arr[2]);
                    } else {
                        return null;
                    }
                }
                if ((navigator.userAgent.match(/(iPhone|iPod|Android|Windows Phone)/i))) {
                    if(getCookie('mfjian') == null) {
                        var url = window.location.href;
                        url = url.replace('http://yourdomain', 'http://m.yourdomain');
                        url = url.replace('https://yourdomain', 'https://m.yourdomain');
                        url = url.replace('http://www.', 'http://m.');
                        url = url.replace('https://www.', 'https://m.');
                        location.replace(url);
                    }
                }/*else{
                    var curProtocol = window.location.protocol.split(':')[0];
                    if (curProtocol === 'http') {
                        var url=window.location.href;
                        url=url.replace('http://','https://');
                        location.replace(url);
                    }
                }*/
            </script>
            
            
             在电脑模板head中加入
  • sunbingchen #5 · 2019-12-12 07:14:28
    唉呦喂 万分感谢
  • sunbingchen #6 · 2019-12-12 13:57:59
    唉呦喂 这个代码好像有点问题,首页一直在加载
  • 唉呦喂 #7 · 2019-12-12 14:04:54
    有地址吗,我帮你看看
  • sunbingchen #8 · 2019-12-12 14:20:35
    满意答案
    唉呦喂 http://www.tyjs158.com/ 应该是yourdomain没替换干净,现在应该是好了
  • sunbingchen #9 · 2019-12-14 09:55:48
    回复迅睿框架创始人 我应该是找到了原因,
    微信截图_20191214095116
    关键就出在了 var is_mobile_cms = '{IS_MOBILE}'; 或许是模版相比官方的改动有点大, 模版是我使用脚手架生成的,https://github.com/xizon/uix-kit/ 使用chrome开发模式 模拟手机访问后,导航的链接全变成了手机链接 var is_mobile_cms = '1'; 没有清空应该全站静态后,这个地方就不能使用php调用了吧 。反正我注释掉就好了,也不知道会不会有其他问题
  • sunbingchen #10 · 2020-12-24 11:17:10
    @sunbingchen:感谢,问题已解决

迅睿系统漏洞

IP138查询
IP138查询(2026-09-02)
转换本地ip地址作用。后台安装/启用插件 Ip_ysb进入「应用 →...
GeoSeo工具箱
GeoSeo工具箱(2026-09-02)
优化城市落地页全选
GEO系统
GEO系统(2026-09-02)
支持最新的ai优化算法 后台增加可控制的站点运营管理
外贸多语言建站
外贸多语言建站(2026-09-02)
修正重复数据传参 增加CLI模式说明
开发者工具
开发者工具(2026-09-02)
增加插件脚手架 增加控制器编写辅助
用户系统
用户系统(2026-09-02)
增强用户列表安全验证,防止个人信息泄露
节日灯笼
节日灯笼(2026-09-01)
新增顶部节日横幅 Banner ,祝福语文字 新增节日特效:Can...
GeoSeo收录宝
GeoSeo收录宝(2026-09-01)
升级 ai智能发布功能 升级 支持8国语言后端设置和前端输出功能 ...