是否是pc端、
function isPc() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone", "symbianOS", "Windows Phone", "iPad", "iPod"]
var flag = true;
for (var i = 0; i < Agents.length; i++) {
if (userAgentInfo.indexOf(Agents[i]) > 0) {
flag = false
break
}
}
return flag
}
是否是IOS
function isIOS() {
var u = navigator.userAgent;
if (u.indexOf("Android") > -1 || u.indexOf("Linux") > -1) {
return false
} else if (u.indexOf("iPhone") > -1) {
return true
} else if (u.indexOf('iPad') > -1) {
return false
} else if (u.indexOf('Windows Phone') > -1) {
return false
} else {
return false
}
}
是否是IE
function isIEBrowser() {
var ua = window.navigator.userAgent
return !!ua.match(/compatible|MSIE|Trident/i)
}
是否是移动端
function isDeviceMobile(){
var ua = window.navigator.userAgent
return /android|webos|iphone|ipod|balckberry/i.test(ua)
}
是否是IE10浏览器
function isIE10(){
var ua = window.navigator.userAgent
return ua.indexOf('MSIE')>=0
}
是否是IE11浏览器
function isIE11(){
let ua = window.navigator.userAgent.toLocaleLowerCase();
return ua.indexOf("rv:11")>-1&&ua.indexOf("trident")>-1;
}