Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Created September 14, 2012 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Takazudo/3721994 to your computer and use it in GitHub Desktop.
Save Takazudo/3721994 to your computer and use it in GitHub Desktop.
IE version detection
# IE version detection
# original: http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/
ie = do ->
version = 3
div = document.createElement 'div'
all = div.getElementsByTagName 'i'
refresh = ->
version += 1
div.innerHTML = '<!--[if gt IE ' + (version) + ']><i></i><![endif]-->'
return
refresh()
while all[0]
refresh()
return version if version > 4
false
alert ie # your version
// IE version detection
// original: http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/
var ie;
ie = (function() {
var all, div, refresh, version;
version = 3;
div = document.createElement('div');
all = div.getElementsByTagName('i');
refresh = function() {
version += 1;
div.innerHTML = '<!--[if gt IE ' + version + ']><i></i><![endif]-->';
};
refresh();
while (all[0]) {
refresh();
}
if (version > 4) {
return version;
}
return false;
})();
alert(ie);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment