Created
October 13, 2017 15:14
-
-
Save codyogden/07a33648ee46065d40804bbfdb30d7cb to your computer and use it in GitHub Desktop.
Detect the version of Internet Explorer (not Edge)
This file contains hidden or 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
/** | |
* Get IE Version | |
* @returns {integer} Version of Internet Explorer, or 0 | |
*/ | |
function GetIEVersion() { | |
var sAgent = window.navigator.userAgent; | |
var Idx = sAgent.indexOf("MSIE"); | |
// If IE, return version number. | |
if (Idx > 0) | |
return parseInt(sAgent.substring(Idx+ 5, sAgent.indexOf(".", Idx))); | |
// If IE 11 then look for Updated user agent string. | |
else if (!!navigator.userAgent.match(/Trident\/7\./)) | |
return 11; | |
else | |
return 0; //It is not IE | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment