Ido Turg
Ido Turg

Reputation: 101

Is it possible to detect all versions of IE with Javascript? How?

Very new to web development, bear with me.

I want to check if the browser used is IE (all versions).

I need to change CSS if IE is detected.

Point me in right direction please.

Upvotes: 8

Views: 6148

Answers (2)

U r s u s
U r s u s

Reputation: 6978

This is the JS I use

(function detectIE() {
  var ua = window.navigator.userAgent;
  var msie = ua.indexOf('MSIE ');
  var trident = ua.indexOf('Trident/');
  var edge = ua.indexOf('Edge/');
  if (msie > 0) {
    // IE 10 or older 
    //Do some stuff
  }
  else if (trident > 0) {
    // IE 11 
    //Do some stuff
  }
  else if (edge > 0) {
    // Edge 
    //Do some stuff
  }
  else
    // other browser
    return false;
})();

Upvotes: 20

Süresh AK
Süresh AK

Reputation: 363

var configValues = getUserAgentValues();
var browserName = configValues.browser_name ;
var browserVersion = configValues.browser_vers;
var OSVersion = configValues.platform_type;     

Please check this once.

Upvotes: -4

Related Questions