Skip to content

Instantly share code, notes, and snippets.

@jesgundy
Created January 24, 2014 19:51
Show Gist options
  • Save jesgundy/8604867 to your computer and use it in GitHub Desktop.
Save jesgundy/8604867 to your computer and use it in GitHub Desktop.
Down and dirty IE detection script. Works on IE11.
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
else if (navigator.appName == 'Netscape')
{
var ua = navigator.userAgent;
var re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
var browser = getInternetExplorerVersion();
if (browser > 0) {
docElement.className = 'ie';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment