Skip to content

Instantly share code, notes, and snippets.

@codyogden
Created October 13, 2017 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codyogden/07a33648ee46065d40804bbfdb30d7cb to your computer and use it in GitHub Desktop.
Save codyogden/07a33648ee46065d40804bbfdb30d7cb to your computer and use it in GitHub Desktop.
Detect the version of Internet Explorer (not Edge)
/**
* 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