Skip to content

Instantly share code, notes, and snippets.

@adeubank
Created March 30, 2015 17: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 adeubank/172b42192ce609a45144 to your computer and use it in GitHub Desktop.
Save adeubank/172b42192ce609a45144 to your computer and use it in GitHub Desktop.
Internet Explorer Version detection and append a ie class to the body
var internetExplorerVersion = (function (){
if (window.ActiveXObject === undefined) return null;
if (!document.querySelector) return 7;
if (!document.addEventListener) return 8;
if (!window.atob) return 9;
if (!document.__proto__) return 10;
return 11;
})();
if (internetExplorerVersion) {
if (internetExplorerVersion == 8) {
document.getElementsByTagName('body')[0].className+=' ie8'
}
else if (internetExplorerVersion == 9) {
document.getElementsByTagName('body')[0].className+=' ie9'
}
else if (internetExplorerVersion == 10) {
document.getElementsByTagName('body')[0].className+=' ie10'
}
else {
document.getElementsByTagName('body')[0].className+=' ie'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment