8

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.

Ido Turg
  • 103
  • 1
  • 5

2 Answers2

20

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;
})();
U r s u s
  • 6,680
  • 12
  • 50
  • 88
-4
var configValues = getUserAgentValues();
var browserName = configValues.browser_name ;
var browserVersion = configValues.browser_vers;
var OSVersion = configValues.platform_type;     

Please check this once.

Süresh AK
  • 344
  • 3
  • 20
  • 1
    Dear Suresh, it appears you are unacquainted with how SO works. The purpose of SO is to provide working code snippets and techniques to be used in production. While I have no doubt your snippet of code above works well for you, it does not work for anybody else. Please post the rest of your code that defines all of these methods and properties, or, if you feel uncomfortable with that, please delete your answer from this question. – Jack G Jan 28 '18 at 19:34