js判断设备是ios还是android

function deviceType(){
        
            var u = navigator.userAgent, app = navigator.appVersion;
            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
            var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            if (isAndroid) {
              return 2;
            }
            if (isIOS) {
            return 1;
            }
        
    }

 

posted @ 2020-09-24 16:29  A-zero  阅读(1451)  评论(0编辑  收藏  举报