Skip to content

Instantly share code, notes, and snippets.

@tborychowski
Last active December 19, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tborychowski/5950042 to your computer and use it in GitHub Desktop.
Save tborychowski/5950042 to your computer and use it in GitHub Desktop.
JS :: detect IE
// the quickest way - by the bug :-)
var IE = !+"\v1"
// the right way
var IE = (function (i, p, undef) {
var br = p.getElementsByTagName('br');
do { p.innerHTML = '<!--[if gt IE ' + (++i) + ']><br><![endif]-->'; } while (br[0]);
return i > 4 ? i : undef;
}(3, document.createElement('p'), false));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment