Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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