Javascript通过识别userAgent跳转到移动终端的主页

Javascript通过识别userAgent跳转到移动终端的主页

以下Javascript代码是通过判断访问客户端的userAgent的值跳转到移动端index.html的首页,供参考:

<script type="text/javascript">
  !function(){
    if(/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/i.test(navigator.userAgent.toLowerCase()) == true){
        location.href = '//chiji.qq.com/m/index.html';
    }
}();
</script>

 

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容