var trident = !!window.ActiveXObject
console.log(trident)
var isIE = "ActiveXObject" in window
console.log(isIE)
var isIE = window.ActiveXObject !== undefined
console.log(isIE)
var docMode = document.documentMode,
hasDocumentMode = (docMode !== undefined),
isIE8 = (docMode === 8),
isIE9 = (docMode === 9),
isIE10 = (docMode === 10),
isIE11 = (docMode === 11),
isMsEdge = window.navigator.userAgent.indexOf("Edge/") > -1;
// browser is IE
if(hasDocumentMode) {
if(isIE11){
// browser is IE11
} else if(isIE10){
// browser is IE10
} else if(isIE9){
// browser is IE9
} else if(isIE8){
// browser is IE8
}
} else {
// document.documentMode is deprecated in MS Edge
if(isMsEdge){
// browser is MS Edge
}
}
判断是否IE浏览器
最新推荐文章于 2024-05-12 13:29:39 发布
这段代码主要用于检测用户使用的是否是InternetExplorer浏览器的不同版本(8,9,10,11)或MicrosoftEdge。它通过检查`ActiveXObject`的存在,`document.documentMode`属性以及用户代理字符串来识别浏览器类型。
摘要由CSDN通过智能技术生成