-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
let util = {} | ||
|
||
util.getBrowserVersion = function () { | ||
let userAgent = navigator.userAgent //取得浏览器的userAgent字符串 | ||
|
||
if (userAgent.indexOf("Firefox") > -1) { | ||
let version = userAgent.match(/firefox\/[\d.]+/gi)[0].match(/[\d]+/)[0] | ||
return "Firefox "+version | ||
} else if (userAgent.indexOf("Edge") > -1) { | ||
let version = userAgent.match(/edge\/[\d.]+/gi)[0].match(/[\d]+/)[0] | ||
return "Edge "+version | ||
} else if (userAgent.indexOf("rv:11") > -1) { | ||
return "IE 11" | ||
} else if (userAgent.indexOf("Opera") > -1 || userAgent.indexOf("OPR") > -1) { | ||
if (userAgent.indexOf("Opera") > -1) { | ||
let version = userAgent.match(/opera\/[\d.]+/gi)[0].match(/[\d]+/)[0] | ||
return "Opera "+version | ||
} | ||
if (userAgent.indexOf("OPR") > -1) { | ||
let version = userAgent.match(/opr\/[\d.]+/gi)[0].match(/[\d]+/)[0] | ||
return "Opera "+version | ||
} | ||
} else if (userAgent.indexOf("Chrome") > -1) { | ||
let version = userAgent.match(/chrome\/[\d.]+/gi)[0].match(/[\d]+/)[0] | ||
return "Chrome "+version | ||
} else if (userAgent.indexOf("Safari") > -1) { | ||
let version = userAgent.match(/safari\/[\d.]+/gi)[0].match(/[\d]+/)[0] | ||
return "Safari "+version | ||
} else if (userAgent.indexOf("MSIE") > -1 || userAgent.indexOf("Trident") > -1) { | ||
if (userAgent.indexOf("MSIE") > -1) { | ||
let version = userAgent.match(/msie [\d.]+/gi)[0].match(/[\d]+/)[0] | ||
return "IE "+version | ||
} | ||
if (userAgent.indexOf("Trident") > -1) { | ||
let versionTrident = userAgent.match(/trident\/[\d.]+/gi)[0].match(/[\d]+/)[0] | ||
let version = parseInt(versionTrident) + 4 | ||
return "IE "+version | ||
} | ||
} else { | ||
return "Unknown" | ||
} | ||
} | ||
|
||
export default util |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.