美文网首页
js设备判断

js设备判断

作者: 池鱼_故渊 | 来源:发表于2020-09-03 15:25 被阅读0次
let d = navigator.userAgent
return{
                trident: d.indexOf('Trident') > -1,
                presto: d.indexOf('Presto') > -1,
                webKit: d.indexOf('AppleWebKit') > -1,
                gecko: d.indexOf('Gecko') > -1 && d.indexOf('KHTML') == -1,
                mobile: !!d.match(/AppleWebKit.*Mobile.*/) || !!d.match(/AppleWebKit/),
                ios: !!d.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
                android: d.indexOf('Android') > -1 || d.indexOf('Linux') > -1,
                iPhone: d.indexOf('iPhone') > -1 || d.indexOf('Mac') > -1,
                iPad: d.indexOf('iPad') > -1,
                webApp: d.indexOf('Safari') == -1,
                Wp: d.indexOf('Windows Phone') > -1,
                weiXi: d.toLowerCase().indexOf('micromessenger') > -1
}

相关文章

网友评论

      本文标题:js设备判断

      本文链接:https://www.haomeiwen.com/subject/ejfosktx.html