title: How to select a div within an iframe?
body: <p>I'm trying to take the contents of a div within an iframe, delete the iframe, and display only  the div. I can't figure out why this won't work- I am not sure of whether to use contentWindow or contentDocument.. Any pointers? Thanks!</p>
  
  <p>I have one div with id "iframe", within that the iframe with id "embedded_article", </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function getContentFromIframe()
  
  {    
  var parent = document.getElementById('iframe');
  var child = document.getElementById('embedded_article');
  
  var oldContent = child.contentWindow.document.innerHTML;
  
  var newContent = child.contentWindow.document.getElementById('ec-article').innerHTML;
  
    document.getElementById('iframe').removeChild(document.getElementById('embedded_article'));
  
  
  parent.innerHTML = newContent;    
  
  }
  &lt;/script&gt;
  </code></pre>