首页 > 设计 > WEB开发 > 正文

pc与移动端互相跳转

2019-11-02 18:00:32
字体:
来源:转载
供稿:网友
1、移动端检测是否是PC端浏览器
<script data-fixed="true">  !function(){    if(/iphone|ios|android|ipod/i.test(navigator.userAgent.toLowerCase()) == false){      location.href = 'PC地址';    }  }();</script>
<!--ignore-->
2、PC端检测是否是移动设备

<script data-fixed="true">  !function(){    function params(u, p){      var m = new RegExp("(?:&|/?)"+p+"=([^&$]+)").exec(u);      return m ? m[1] : '';    }    if(/iphone|ios|android|ipod/i.test(navigator.userAgent.toLowerCase()) == true && params(location.search, "from") != "mobile"){      location.href = '移动端地址';    }  }();</script>
<!--ignore-->

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表