Skip to content

Instantly share code, notes, and snippets.

@peponi
Created January 13, 2016 13:03
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 peponi/3a83d9d9ba31a48e769c to your computer and use it in GitHub Desktop.
Save peponi/3a83d9d9ba31a48e769c to your computer and use it in GitHub Desktop.
detect any IE Browser. checks for ActiveXObject which is exclusively available on IE. Works for IE5 -11. Use only when feature detection won't give desired results.
//place script in head and after modernizr.
(function(){
var html = document.getElementsByTagName('HTML')[0];
if("ActiveXObject" in window){
html.className += ' is-IE';
}
})()
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment