title: Ensuring that onLoad of an IFRAME doesn't execute too soon
body: <p>I just discovered that the source of my issues is that the parent HTML makes calls to controls in a child IFRAME <strong>but</strong> is too quick about that and, sometimes, the super <em>onLoad</em> attempts to do so <strong>before</strong> the sub <em>onLoad</em> had a chance to add stuff to the DOM.</p>
  
  <p>What can I do about it?</p>
  
  <p>I've tried to set up some kind of feed-back from <em>onLoad</em> in the child. Failed miserably with so many strange errors that they can be summarized by <em>dude, just please don't</em>.</p>
  
  <p>I've tried to set up a delayer, which is ugly of epic proportions <strong>and</strong> not 100% reliable.</p>
  
  <p>EDIT:</p>
  
  <p>In <code>onload</code> I do this:</p>
  
  <pre><code>var stuff = getReferenceToStuff();
  var someDiv = stuff.contentWindow.document.getElementById("someDiv");
  someDiv.className = "classy";
  </code></pre>
  
  <p>The problem is that <strong>sometimes</strong> the reference <em>someDiv</em> is <em>null</em> and sometimes (often when I reload the page by F5), it points to the correct element. I know it's because the contents of the IFRAME are a bit slower.</p>
  
  <p>So my questions is this. How can I ensure that <em>onload</em> is postponed until the embedded IFRAME component's <em>onload</em> ensures that it's been loaded and all the components are there?</p>