Skip to content

Instantly share code, notes, and snippets.

@terkel
Created December 9, 2011 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save terkel/1452154 to your computer and use it in GitHub Desktop.
Save terkel/1452154 to your computer and use it in GitHub Desktop.
Detect IE and add class to the html element
// 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