Skip to content

Instantly share code, notes, and snippets.

@lerivin
Created May 5, 2012 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lerivin/2604219 to your computer and use it in GitHub Desktop.
Save lerivin/2604219 to your computer and use it in GitHub Desktop.
An IE detection script with css setup via jQuery
var ieDetection = (function(){
var
minVersion = 7
, maxVersion = 10
, currentVersion = minVersion
;
while(currentVersion <= maxVersion) {
var div = $('<div></div>').css('display', 'none');
var string = '<!--[if IE '
+ currentVersion
+ ']><script>'
+ '$(document.body).addClass("ie' + currentVersion + '");'
+ '</script><![endif]-->';
div.html(string)
$(document.body).append(div);
currentVersion++;
}
}
);
$(document).ready(
function(){
ieDetection();
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment