Forked from scottjehl/detect IE and version number through injected conditional comments.js
Created
August 23, 2010 14:31
-
-
Save johnantoni/545590 to your computer and use it in GitHub Desktop.
ie conditional comment detect
This file contains hidden or 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
// detect Internet Explorer and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check) | |
// | |
// author: Scott Jehl | |
// | |
// http://gist.github.com/scottjehl | |
// | |
// version arg is for IE version (optional) | |
// comparison arg supports 'lte', 'gte', etc (optional) | |
// | |
// is it IE? | |
// isIE(); | |
// | |
// is it IE6? | |
// isIE(6); | |
// | |
// is it less than or equal to IE 7? | |
// isIE(7,'lte'); | |
var isIE = (function(){ | |
var doc = document, | |
doc_elem = doc.documentElement, | |
cache = {}, | |
elem; | |
return function( version, comparison ) { | |
if(/*@cc_on!@*/true){return false;} | |
var key = [ comparison || '', 'IE', version || '' ].join(' '); | |
if ( cache[ key ] === undefined ) { | |
elem = elem || doc.createElement( 'B' ); | |
elem.innerHTML = '<!--[if '+ key +']><b></b><![endif]-->'; | |
cache[ key ] = !!elem.getElementsByTagName( 'b' ).length; | |
} | |
return cache[ key ]; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
different version here
http://ajaxian.com/archives/attack-of-the-ie-conditional-comment