title: Problem with Google Chrome and Javascript. Guru needed!
body: <p>i have a strange problem <strong>only in Chrome</strong> using an <code>iframe</code> but working in all others common browser.</p>
  
  <p>the problem: If i type in the IFRAME and then press the button to send, it work fine, the focus back to the IFRAME and the cursor BLINK.</p>
  
  <p>But if i type and then press ENTER to invoke the event handler function, the focus back but the cursor disappear. And then if you go in another window and then back the cursor appear. <strong>This happen only in Chrome</strong>. I did the example page to show the problem in action. Click the link below to see.</p>
  
  <p><strong>UPDATE: I added the code also here below</strong></p>
  
  <pre><code>    var editorFrame = 'myEditor'
  
  function addFrame() {
  
      var newFrame = new Element('iframe', {
          width: '520', 
          height: '100',
          id: editorFrame,
          name: editorFrame,
          src: 'blank.asp',
          class: 'myClass'
      });
  
      $('myArea').appendChild(newFrame);
  
      window.iframeLoaded = function() {
          // this is call-back from the iframe to be sure that is loaded, so can safety attach the event handler
  
          var iframeDoc, UNDEF = "undefined";
          if (typeof newFrame.contentDocument != UNDEF) {
              iframeDoc = newFrame.contentDocument;
          } else if (typeof newFrame.contentWindow != UNDEF) {
              iframeDoc = newFrame.contentWindow.document;
          }
          if (typeof iframeDoc.addEventListener != UNDEF) {
              iframeDoc.addEventListener('keydown', keyHandler, false);
          } else if (typeof iframeDoc.attachEvent != UNDEF) {
              iframeDoc.attachEvent('onkeydown', keyHandler);  
          }
      };
  }
  
  function resetContent() 
  {   
      var myIFrame = $(editorFrame);
  
      if (myIFrame) myIFrame.contentWindow.document.body.innerHTML='';
  }
  
  function setEditFocus() 
  {
  
      var iFrame = document.frames ? document.frames[editorFrame] : $(editorFrame);
      var ifWin = iFrame .contentWindow || iFrame;
  
      ifWin.focus();
  
  }
  
  function send()
  {
      resetContent();
      setEditFocus(); 
  }
  
  function keyHandler (evt) {
  
      var myKey=(evt.which || evt.charCode || evt.keyCode)
  
      if (myKey==13)  {
  
          if (!evt) var evt = window.event;
  
          evt.returnValue = false;
  
          if (Prototype.Browser.IE) evt.keyCode = 0;
  
          evt.cancelBubble = true;
  
          if (evt.stopPropagation) evt.stopPropagation();
  
          if (evt.preventDefault) evt.preventDefault();
  
          send();
  
      }
  }
  </code></pre>
  
  <p>In the HTML page</p>
  
  <pre><code>&lt;body onload="addFrame()"&gt;
  
  &lt;div id="myArea"&gt;&lt;/div&gt;
  &lt;input id="myButton" type="button" value="click me to send [case 1]" onclick="send()"&gt;
  </code></pre>
  
  <p>To make more easy to understand the problem i've create a <strong>specific page to reproduce the problem</strong> with full example and source included.</p>
  
  <p>You can view here by using Google Chrome:
  <a href="http://under.bestqm.com/test/iframe.asp" rel="nofollow noreferrer">example of the problem</a> </p>
  
  <p>I really need your help because i tried to solve this problem for many days with no luck. And all the suggestions, tips and workaround are well accepted.</p>
  
  <p>Thanks in advance.</p>