title: IE8 fallback for addEventListener breaks code for modern browsers
body: <p><a href="https://stackoverflow.com/questions/9769868/addeventlistener-not-working-in-ie8">Drawing off the explanation provided in this example</a>, I added the following code to my html as part of an immediately invoked function expression:</p>
  
  <pre><code>(function hideOverlayOnEsc(){
      document.addEventListener('keydown', function(e){
          if( e.keyCode == '27' ){
              cmnOverlayV2.hideOverlay();
          }
      }, false);
  
      // IE8 Fix
      if(!document.addEventListener){ 
          document.attachEvent("onkeydown", function(e){
              if( e.keyCode == '27' ){
                  cmnOverlayV2.hideOverlay();
              }
          });
      }
  })();
  </code></pre>
  
  <p>When these two versions of applying the event listener to the document are used separately, they work as intended. That is to say, that if the <code>IE8 fix</code> is removed, the code works properly in other browsers. And if the <code>addEventListener</code> code block is removed, it works properly in IE8. However, having both of these code blocks in place currently breaks the html in some way for at least one of the two browser categories (ie8 &amp; not ie8)</p>
  
  <p>Some additional information for reference:</p>
  
  <p>The <code>document</code> object was used because the actual html element that should hide on Escape does not load into the DOM initially, and this was an easy way around that.</p>
  
  <p>This code block functions properly (when one of the two inner code blocks are omitted) as either an inline <code>&lt;script&gt;</code> call or an external <code>.js</code> file's call.</p>
  
  <p>The html in which this code block lives is injected into the DOM of another html document. In other words, what I am working with is just a part of the whole page that is added dynamically. Because of this, when I say the html is 'broken' what actually happens is the html I am editing is not present in the DOM of the parent html document.</p>
  
  <p>I had considered setting up conditional comments to say something like <code>&lt;!--[if IE8]&gt;USE SCRIPT B&lt;![endif]--&gt;</code> but this is difficult because I do not have access to the <code>&lt;head&gt;</code> section of the parent html. I would prefer to just work this out within the <code>hideOverlayOnEsc()</code> function if possible.</p>