Created
December 9, 2011 16:11
-
-
Save terkel/1452154 to your computer and use it in GitHub Desktop.
Detect IE and add class to the html element
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
// Including IE detection by James Padolsey: https://gist.github.com/527683 | |
(function (html) { | |
var ie = (function () { | |
var undef, | |
v = 3, | |
div = document.createElement('div'), | |
all = div.getElementsByTagName('i'); | |
while (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', all[0]); | |
return (v > 4)? v: undef; | |
}()); | |
if (ie) { | |
html.className += ' ie' + ie; | |
} | |
})(document.documentElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment