title: Display iframe div contents on parent page
body: <p>I'm sure this is pretty basic, but I can't seem to get any of the solutions I've found to work for me. Basically, I need to get the contents of a div from an iframe, and write them to a div in the parent page. This is what I have:</p>
  
  <pre><code>&lt;iframe src="slideshows/slideshow/case2.html" frameborder=0 scrolling="no" 
  id="frame1" name="frame1"&gt;&lt;/iframe&gt;
  
  &lt;div id="caption"&gt;
     &lt;script type="text/javascript"&gt;
     var caption = frame1.document.getElementById('slidecaption');
     document.write(caption);
     &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>'slidecaption' is the name of Id in the iframe that I'm trying to grab. </p>
  
  <p>All I get is "null". Is it because the iframe contents haven't loaded yet? If so, how do I delay until the iframe has loaded?</p>
  
  <p>Thanks,
  Scott</p>
  
  <hr>
  
  <p>Thanks to both of you for your help. I figured it out, based on Márcio's idea:</p>
  
  <p>I put the function in the parent page:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function send() {
  document.getElementById('slidecaption').innerHTML = 
  frame1.document.getElementById('slidecaption').innerHTML}
  &lt;/script&gt;
  </code></pre>
  
  <p>And I put the call in the iframe document:</p>
  
  <pre><code>&lt;body onload="parent.send();"&gt;
  </code></pre>
  
  <p>Regards,
  Scott</p>