Skip to content

Instantly share code, notes, and snippets.

@ahawthorne
ahawthorne / detect_ie.js
Last active December 17, 2015 20:19
JavaScript to detect IE version using conditional tags and add classes to the html tag.
window.ie = (function() {
var undef,
v = 3,
htmlClass = document.documentElement.className,
div = document.createElement('div'),
all = div.getElementsByTagName('span');
do {
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><span></span><!endif]-->';
} while (all[0]);