This commit is contained in:
fengchenchen
2023-08-14 17:10:11 +08:00
commit 37f6ec895d
1145 changed files with 437754 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
// 判断是否IE<11浏览器
export function isIE () {
return navigator.userAgent.indexOf('compatible') > -1 && navigator.userAgent.indexOf('MSIE') > -1
}
export function isIE11 () {
return navigator.userAgent.indexOf('Trident') > -1 && navigator.userAgent.indexOf('rv:11.0') > -1
}
// 判断是否IE的Edge浏览器
export function isEdge () {
return navigator.userAgent.indexOf('Edge') > -1 && !isIE()
}
export function getIEVersion () {
const userAgent = navigator.userAgent // 取得浏览器的userAgent字符串
const isIEFlag = isIE()
const isIE11Flag = isIE11()
const isEdgeFlag = isEdge()
if (isIEFlag) {
const reIE = new RegExp('MSIE (\\d+\\.\\d+);')
reIE.test(userAgent)
const fIEVersion = parseFloat(RegExp.$1)
if (fIEVersion === 7 || fIEVersion === 8 || fIEVersion === 9 || fIEVersion === 10) {
return fIEVersion
} else {
return 6// IE版本<7
}
} else if (isEdgeFlag) {
return 'edge'
} else if (isIE11Flag) {
return 11
} else {
return -1
}
}