Skip to content

Instantly share code, notes, and snippets.

@terkel
Created December 9, 2011 16:11
Show Gist options
  • Select an option

  • Save terkel/1452154 to your computer and use it in GitHub Desktop.

Select an option

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