Created
March 30, 2015 17:03
-
-
Save adeubank/172b42192ce609a45144 to your computer and use it in GitHub Desktop.
Internet Explorer Version detection and append a ie class to the body
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
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