title: In Javascript setting a textarea with focus() does not work if called as a child window
body: <p>I have a simple test page that sets the focus to a textarea on an oninit function. However the exact code fails to do this if the page is called as a child.</p>
  
  <p>Putting alert box proves that the oninit function is being called but fails to put the focus in the textbox. Pressing reload though does then focus correctly.</p>
  
  <p>So given that my code works perfectly when called on a main page, and also works in a child if reload is called, then why doesn't it work the first time?</p>
  
  <pre><code>&lt;html&gt;
  &lt;body onload="init()"&gt;
  &lt;script type="text/javascript"&gt;
  function init()
  {
      document.getElementById("message").focus();
  }
  
  &lt;/script&gt;
  &lt;textarea id="message" rows=10 cols=40&gt;&lt;/textarea&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Nothing clever here as you can, just only doesn't work if the page is loaded by window.open("test2.html");</p>