Created
April 6, 2010 15:36
-
-
Save scottjehl/357727 to your computer and use it in GitHub Desktop.
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
//EnhanceJS isIE test idea | |
//detect IE and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check) | |
//version arg is for IE version (optional) | |
//comparison arg supports 'lte', 'gte', etc (optional) | |
function isIE(version, comparison) { | |
var cc = 'IE'; | |
if(version){ | |
cc += ' ' + version; | |
if(comparison){ cc = comparison +' '+ cc; } | |
} | |
var b = document.createElement('B'); | |
b.innerHTML = '<!--[if '+ cc +']><b id="iecctest"></b><![endif]-->'; | |
document.documentElement.appendChild(b); | |
var isIE = document.getElementById('iecctest'); | |
document.documentElement.removeChild(b); | |
return !!isIE; | |
} | |
//is it IE? | |
isIE(); | |
//is it IE6? | |
isIE(6); | |
//is it less than or equal to IE 6? | |
isIE(7,'lte'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment