Last active
December 19, 2015 11:49
-
-
Save tborychowski/5950042 to your computer and use it in GitHub Desktop.
JS :: detect IE
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
// the quickest way - by the bug :-) | |
var IE = !+"\v1" |
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
// 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