Created
July 5, 2011 13:32
-
-
Save donabrams/1064841 to your computer and use it in GitHub Desktop.
Add class ieX where X is version to enclosing html tag
This file contains 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
(function () { | |
"use strict"; | |
var browserClass = null; | |
if (navigator.appName === 'Microsoft Internet Explorer') { | |
if (navigator.appVersion.indexOf('MSIE 6', 0) !== -1) { | |
browserClass = "ie6"; | |
} else if (navigator.appVersion.indexOf('MSIE 7', 0) !== -1) { | |
browserClass = "ie7"; | |
} else if (navigator.appVersion.indexOf('MSIE 8', 0) !== -1) { | |
browserClass = "ie8"; | |
} else if (navigator.appVersion.indexOf('MSIE 9', 0) !== -1) { | |
browserClass = "ie9"; | |
} | |
} | |
if (browserClass) { | |
var htmlTag = document.getElementsByTagName("html")[0]; | |
htmlTag.setAttribute("class", browserClass); | |
htmlTag.setAttribute("className", browserClass); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment