Takazudo
9/14/2012 - 1:43 PM

IE version detection

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);