public
Last active

  • Download Gist
detect-ie.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/**
* modified from http://gist.github.com/527683
* only improve slightly to get small
*/
var ie = function(v, p, needle, undef) {
 
needle = p.getElementsByTagName('br');
 
while(
p.innerHTML = '<!--[if gt IE ' + (++v) + ']><br><![endif]-->',
needle[0]
);
 
return v > 4 ? v : undef;
 
}(3, document.createElement('p'));

(you'll need to test p.getElementsByTagName('br')[0] in the while loop)

@cowboy: needle is live nodelist, don't need to re get in loop

How did I not know that? That's really interesting, thanks!

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.