Detect IE Version Using Javascript

 ·  · 

JavaScript snippets for getting Microsoft Windows Internet Explorer (IE) version.

function getIEVersion() {
  var _ieVersion = -1;
  var ua = navigator.userAgent;
  var regx10 =  new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
  var regx11 = new RegExp("Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})")
  if ((ua.exec(regx10) != null) || (ua.exec(regx11) != null)) {
    _ieVersion = parseFloat( RegExp.$1 );
  }

  return _ieVersion;
}