js判断是手机访问还是电脑访问

var url = patt1.exec(location.href);
        if (navigator.userAgent.toLowerCase().indexOf("micromessenger") > -1) {
            window.location.href = "http://www.360doc26.net/wxarticlenew/" + url.toString().split("_")[1] + ".html";
                        
        }
        else if (navigator.userAgent.indexOf("iPhone") > 0 || navigator.userAgent.indexOf("Android") > 0 || navigator.userAgent.indexOf("iPod") > 0) {  //手机端跳转

            if (url != "") {
                self.location = "http://www.360doc.cn/article/" + url + ".html";
            }
        }

 

posted @ 2020-06-26 13:04  netlock  阅读(363)  评论(0编辑  收藏  举报