title: Javascript callback when IFRAME is finished loading?
body: <p>I need to execute a callback when an IFRAME has finished loading. I have no control over the content in the IFRAME, so I can't fire the callback from there.</p>
  
  <p>This IFRAME is programmaticly created, and I need to pass its data as a variable in the callback, as well as destroy the iframe.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is what I have now:</p>
  
  <pre><code>function xssRequest(url, callback)
  {
      var iFrameObj = document.createElement('IFRAME');
      iFrameObj.src = url;            
      document.body.appendChild(iFrameObj);   
  
      $(iFrameObj).load(function() 
      {
          document.body.removeChild(iFrameObj);
          callback(iFrameObj.innerHTML);
      });
  }
  </code></pre>
  
  <p>This callsback before the iFrame has loaded, so the callback has no data returned.</p>