title: How should I detect the IE browser?
body: <p>I've already done feature detection on a particular feature to decide if I can use it or whether I have to use a work-around.  But, unfortunately, I found that IE has some bugs in that feature that render it useless to me even when it's present.  So, even though it passes the feature detection, I need to detect that the browser is IE so I don't use that feature if it's IE.</p>
  
  <p>I've tried to see if I could do feature detection on the actual buggy behavior (which would be best because it would adapt if IE fixes the behavior in the future), but there does not appear to be any way to do that (subject of a <a href="https://stackoverflow.com/questions/12172346/how-to-identify-buggy-behavior-in-input-event-without-browser-detection">different question</a>).  That means I'm left with trying to conclusively identify that it's an IE browser so I can avoid the buggy feature.  <strong>I do not want to use the useragent string</strong> since we all know that it is easily spoofed and can easily be wrong.</p>
  
  <p>So, I'd like to do feature detection on whether it's the IE browser or not.</p>
  
  <p>The approach I have so far is this:</p>
  
  <pre><code>var isIE = (document.body.attachEvent &amp;&amp; window.ActiveXObject);
  </code></pre>
  
  <p>This looks to see if the <code>attachEvent()</code> method is present and if <code>ActiveXObject</code> support is present.  I had to do more than just the <code>attachEvent</code> check because Opera supports <code>attachEvent</code>.</p>
  
  <p>Is this a reliable way to detect IE?  Are there better ways?</p>
  
  <p>Please don't respond with I really shouldn't do browser detection, but should use feature detection instead.  I'm already doing feature detection, but that caused a problem because a browser that "supports" the feature and thus passes feature detection turns out to be so buggy that I can't use the feature in that browser.  So, now I must detect the buggy browser.</p>
  
  <p>If you want to know more about the specific situation this is being used in, it's described in <a href="https://stackoverflow.com/questions/12172346/how-to-identify-buggy-behavior-in-input-event-without-browser-detection">this other question</a>.</p>