/detect IE and version number through injected conditional comments.js
Forked from paulirish/detect IE and version number through injected conditional comments.js
Last active Aug 29, 2015
//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', | |
b = document.createElement('B'), | |
docElem = document.documentElement, | |
isIE; | |
if(version){ | |
cc += ' ' + version; | |
if(comparison){ cc = comparison + ' ' + cc; } | |
} | |
b.innerHTML = '<!--[if '+ cc +']><b id="iecctest"></b><![endif]-->'; | |
docElem.appendChild(b); | |
isIE = !!document.getElementById('iecctest'); | |
docElem.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