title: How can I detect Internet Explorer (IE) and Microsoft Edge using JavaScript?
body: <p>I've looked around a lot, and I understand that there's a lot of ways to detect internet explorer.</p>
  <p>My problem is this: I have an area on my HTML document, that when clicked, calls a JavaScript function that is incompatible with internet explorer of any kind.
  I want to detect if IE is being used, and if so, set the variable to true.</p>
  <p>The problem is, I am writing my code out of Notepad++, and when I run the HTML code in browser, none of the methods for detecting IE work. I think the problem is that I am running it out of Notepad++. I need to be able to detect IE, so that based on the variable, I can disable that area of the site. I have tried this:</p>
  <pre><code>var isIE10 = false;
  
  if (navigator.userAgent.indexOf(&quot;MSIE 10&quot;) &gt; -1) {
      // this is internet explorer 10
      isIE10 = true;
     window.alert(isIE10);
  }
  
  var isIE = (navigator.userAgent.indexOf(&quot;MSIE&quot;) != -1);
  
  if(isIE){
      if(!isIE10){
      window.location = 'pages/core/ie.htm';
      }
  }
  </code></pre>
  <p>but it doesn't work. How can I detect IE out of Notepad++? That's what I'm testing the HTML out of, but I need a method that'll work with that.</p>
  <h1>edit</h1>
  <p>I noticed someone has marked this as a duplicate, and that is understandable. I suppose I was not clear.  I cannot use a JQuery answer, so this is not a duplicate as I am asking for a vanilla JS answer.</p>
  <h1>Edit #2</h1>
  <p>Is there also a way to detect the Microsoft Edge browser?</p>