js 判断访问web是什么设备

/*移动和PC相互切换代码*/
        var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire");
        var browser = navigator.userAgent.toLowerCase(); 
        var isMobile = false; 
        for (var i=0; i<mobileAgent.length; i++){
             if (browser.indexOf(mobileAgent[i])!=-1){
                isMobile = true; 
                //alert(mobileAgent[i]); 
                location.href = 'http://wechat.aabb.cn/';
                break; 
            }

        } 
   <script type="text/javascript">
        function download(){
            var u = navigator.userAgent;
            var device =""; //当前设备信息
            if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
                //安卓手机
                window.location.href ="http://shikeimg.oss-cn-hangzhou.aliyuncs.com/apk/app-release.apk";
            } else if (u.indexOf('iPhone') > -1) {
                //苹果手机
                window.location.href ="https://www.pgyer.com/7zMW"
            } else if (u.indexOf('Windows Phone') > -1) {
                //winphone手机
                window.location.href ="http://shikeimg.oss-cn-hangzhou.aliyuncs.com/apk/app-release.apk";
            }
        }
    </script>

  

原文地址:https://www.cnblogs.com/wz-ctt/p/7612160.html