苏飞论坛

标题: 锐拓云手机访问电脑端自动跳转到手机网站的方法 [打印本页]

作者: 站长苏飞    时间: 2020-11-18 14:38
标题: 锐拓云手机访问电脑端自动跳转到手机网站的方法
锐拓云手机访问电脑端自动跳转到手机网站的方法


教程目录帖:http://www.sufeinet.com/thread-39989-1-1.html


主页的写法


[C#] 纯文本查看 复制代码
   <script>
        if(@Model.requesttype==1){
      window.location.href = "/mindex";
    }else if(@Model.requesttype==2)
    {
       window.location.href = "/mindex";
    }
   </script>
[C#] 纯文本查看 复制代码
requesttype=1
是手机
[C#] 纯文本查看 复制代码
requesttype=2
是微信

模版的写法

[C#] 纯文本查看 复制代码
   <script>
        if(@Model.requesttype==1){
       // PC跳转移动端
           var  url= window.location.href.substring(window.location.href.indexOf(document.domain+"/",0)+(document.domain+"/").length,window.location.href.length);
             window.location.href = "http://"+document.domain+"/m"+url;
    }else if(@Model.requesttype==2)
    {
          var url= window.location.href.substring(window.location.href.indexOf(document.domain+"/",0)+(document.domain+"/").length,window.location.href.length);
             window.location.href = "http://"+document.domain+"/w"+url;
    }
   </script>

有一点请大家谨记,如果要使用这个跳转的方式就不能再启用缓存了,启用缓存会失效






欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4