Created
June 17, 2020 20:32
-
-
Save tmaiaroto/fcf2ca7c1196ef3093e5c877ba8233f3 to your computer and use it in GitHub Desktop.
Detect IE Version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Looks at User Agent to determine if IE and which version | |
function GetIEVersion() { | |
var sAgent = window.navigator.userAgent; | |
var idx = sAgent.indexOf("MSIE"); | |
var versionNumber = 0; | |
// If IE, return version number. | |
if (idx) { | |
try { | |
versionNumber = parseInt(sAgent.substring(idx+ 5, sAgent.indexOf(".", idx))); | |
} catch (e) { | |
// swallow it | |
} | |
} | |
// If IE 11 then look for "Trident" in user agent string. | |
if (!versionNumber && !!navigator.userAgent.match(/trident/gi)) { | |
versionNumber = 11; | |
} | |
// If IE Edge then look for "Edge" in user agent string. | |
if (!versionNumber && !!navigator.userAgent.match(/edge/gi)) { | |
versionNumber = 13; | |
} | |
return versionNumber; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetIEVersion(){var t=window.navigator.userAgent,n=t.indexOf("MSIE"),e=0;if(n)try{e=parseInt(t.substring(n+5,t.indexOf(".",n)))}catch(t){}return!e&&navigator.userAgent.match(/trident/gi)&&(e=11),!e&&navigator.userAgent.match(/edge/gi)&&(e=13),e} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment