title: attachEvent versus addEventListener
body: <p>I'm having troubles getting the attachEvent to work. In all browsers that support the addEventListener handler the code below works like a charm, but in IE is a complete disaster. They have their own (incomplete) variation of it called attachEvent. </p>
  
  <p>Now here's the deal. How do I get the attachEvent to work in the same way addEventListener does?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>function aFunction(idname)
  {
      document.writeln('&lt;iframe id="'+idname+'"&gt;&lt;/iframe&gt;');
      var Editor = document.getElementById(idname).contentWindow.document;
  
      /* Some other code */
  
      if (Editor.attachEvent)
      {
          document.writeln('&lt;textarea id="'+this.idname+'" name="' + this.idname + '" style="display:none"&gt;'+this.html+'&lt;/textarea&gt;');
          Editor.attachEvent("onkeyup", KeyBoardHandler);
      }
      else
      {
          document.writeln('&lt;textarea id="hdn'+this.idname+'" name="' + this.idname + '" style="display:block"&gt;'+this.html+'&lt;/textarea&gt;');
          Editor.addEventListener("keyup", KeyBoardHandler, true);
      }
  }
  </code></pre>
  
  <p>This calls the function KeyBoardHandler that looks like this:</p>
  
  <pre><code>function KeyBoardHandler(Event, keyEventArgs) {
      if (Event.keyCode == 13) {
          Event.target.ownerDocument.execCommand("inserthtml",false,'&lt;br /&gt;');
          Event.returnValue = false;
      }
  
      /* more code */
  }
  </code></pre>
  
  <p>I don't want to use any frameworks because A) I'm trying to learn and understand something, and B) any framework is just an overload of code I'm nog going to use.</p>
  
  <p>Any help is highly appreciated!</p>