title: onkeydown crossbrowser on IFRAME?
body: <p>before to post i try to search a solution in this site and by google but with now luck.</p>
  
  <p><strong>I have a issue with IE8</strong>, this code below add on the fly an IFRAME and work fine in Chrome, Firefox and IE7.</p>
  
  <p>The problem is the keyHandler() function that is <strong>not triggered only in IE8</strong>.</p>
  
  <p>What is the best solution to attach an event crossbrowser as onkeydown?</p>
  
  <p><em>(also Safari and Opera will be nice to support, will be IE9 also supported with this code?)</em></p>
  
  <p>p.s. i currently use <em>prototype.js</em>, the embeded <em>blank.htm</em> have the <em>contenteditable on</em> and the properly DOCTYPE -> (also in the main page where the function is called)</p>
  
  <p>I post the code below and thanks in advance for suggestion and tips</p>
  
  <pre><code>function addFrame() {
  var editorFrame = 'myEditor', iFrame;
  
  var newFrame = new Element('iframe', {width: '320px', height: '70px',id: editorFrame, name: editorFrame, src:'/blank.htm'});
  
  $('container').appendChild(newFrame);
  
  if(document.all) {
      iFrame = window.frames[editorFrame];
  
      if (window.document.addEventListener)
          iFrame.document.addEventListener('keydown', keyHandler, false);
      else 
          iFrame.document.attachEvent('onkeydown', keyHandler);  // OK IE7
  }
  else {
      // OK Firefox, Chrome
      iFrame = $(editorFrame).contentWindow;
      iFrame.addEventListener('keydown', keyHandler, false);
  }
  </code></pre>
  
  <p>}</p>