detect the ie version on the client side  [ 917 views ]

Goal: feature specific ie version detection

I’ve found somewhere a tricky solution for this problem. Here is a little bit modified version of that:

// ie version detector
var isIE = (function() {
  var undef,
      v = 3,
      span = document.createElement('span');
  while (
    span.innerHTML = '<!--[if gt IE ' + (++v) + ']>.<![endif]-->',
    span.innerHTML[0] == '.'
  );
  v = !!navigator.appVersion.match(/MSIE 10/) ? 10 : v;
  v = !!window.MSInputMethodContext ? 11 : v;

  return v > 4 ? v : undef;  
}());

The isIE variable will be the version number if we have an internet explorer in other cases this variable will be undefined.
The original method not working above ie9, that’s why I put a simple ie10 detection based on the navigator version and a feature detection to the ie11. !!window.MSInputMethodContext will be true in ie11!

#sidebar a { color:#fff; } #sidebar ul ul li { color: #DEF585; } #sidebar h2 { color: #fff; } #sidebar ul p, #sidebar ul select { color: #BEDDBE; } #backfly { background: url(images/golfBallWallPaper.jpg) left bottom fixed repeat-x #65a51d; }