Waiting for child window loading to complete
<p>Is there an easy hook for detecting that a window opened by a script has finished loading? Basically, I want the equivalent of the <code>onLoad()</code> hook, but I can't set it directly -- assume that the child document is a given and I can't actually put any code of my own in it.</p>

<p>For instance, say I have the following two files:</p>

<p><code>parent.html</code>:</p>

<pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Parent&lt;/title&gt;
  &lt;/head&gt;
  &lt;script type="text/javascript"&gt;
    var w;
    function loadChild() {
      w = window.open();
      w.location.href="child.html";
      // block until child has finished loading... how?
      w.doSomething();
    } 
  &lt;/script&gt;
&lt;/html&gt;
&lt;body&gt;
  I am a parent window. &lt;a href="javascript:loadChild()"&gt;Click me&lt;/a&gt;.
&lt;/body&gt;
</code></pre>

<p><code>child.html</code>:</p>

<pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Child&lt;/title&gt;
  &lt;/head&gt;
  &lt;script type="text/javascript"&gt;
    function doSomething() {
      alert("Hi there");
    }
  &lt;/script&gt;
&lt;/html&gt;
&lt;body&gt;
  I am a child window
&lt;/body&gt;
</code></pre>

<p>Since setting location.href is non-blocking, <code>w.doSomething()</code> isn't defined yet and the <code>doSomething()</code> call blows up. How can I detect that the child has finished loading?</p>
