js判断设备类型

1.检测安卓,苹果和windows phone的手机

var ua = navigator.userAgent;
var url;

if(ua.match(/WindowssPhone/i) !=null){
    console.log('this is Windowsphone ');
}
else if(ua.match(/iPhone|iPod/i) != null){
    url = "itms-apps://itunes.apple.com/app/id959587493";
    window.setTimeout(function () {
        window.location.href = url;
    },10);
}
else if(ua.match(/Android/i) != null){
    url = "http://a.app.qq.com/o/simple.jsp?pkgname=com.electric.chargingpile";
    window.setTimeout(function () {
        window.location.href = url;
    },10);
}

var ua = navigator.userAgent;
        var url;

        if(ua.match(/WindowssPhone/i) !=null){
            console.log('this is Windowsphone ');
        }
        else if(ua.match(/iPhone|iPod/i) != null){
            url = "itms-apps://itunes.apple.com/app/id959587493";
            window.setTimeout(function () {
                window.location.href = url;
            },10);
        }
        else if(ua.match(/Android/i) != null){
            url = "http://a.app.qq.com/o/simple.jsp?pkgname=com.electric.chargingpile";
            window.setTimeout(function () {
                window.location.href = url;
            },10);
        }

判断设备为微信内的浏览器

2.if ((/MicroMessenger/i).test(window.navigator.userAgent)) {}

原文地址:https://www.cnblogs.com/isdom/p/webclips043.html