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.

5

2 Answers 2

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;
})();
Sign up to request clarification or add additional context in comments.

1 Comment

This looks like what I'm after. I will accept when it let me.
-4
var configValues = getUserAgentValues();
var browserName = configValues.browser_name ;
var browserVersion = configValues.browser_vers;
var OSVersion = configValues.platform_type;     

Please check this once.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.