title: Read data from iframe with JavaScript
body: <p>My problem is as follows: <br/>
  I designed a homepage and I Have a index (www.abc.com) site and a site with news(www.abc.com/index.html).</p>
  
  <p>I tried to bring my headlines of all the news automatically to my index site. Therefore I programmed a small javascript function and it works locally but it doesn't work when it goes online. </p>
  
  <p>The way I'm doing this is: </p>
  
  <ol>
  <li>Include an iframe (www.abc.com/index.html) in my index</li>
  <li>iframe is not visible</li>
  <li>Getting the structure of the iframe in my JS</li>
  <li>Picking out the information I need for the index</li>
  <li>Copy the data into my index</li>
  </ol>
  
  <p>I know that I can't get data out from iframes which are not in my webspace, but this is in my webspace.</p>
  
  <pre><code>&lt;iframe name="nf" id="newsframe" src="http://www.rossegger.at/news.html" 
  style="visibility:hidden"&gt;&lt;/iframe&gt;
  &lt;table id="news_table"&gt;&lt;/table&gt;
  
  
  function load_news() {    
      var con = document.getElementById("news_table");
      var frame = window.frames['nf'].document.getElementsByClassName('n');
  
      if(frame.length != 0)
      {
          con.innerHTML += "&lt;tr&gt;&lt;h2 color=white&gt;NEWS&lt;/h2&gt;&lt;/tr&gt;&lt;hr&gt;";
          for(var i=0; i&lt;frame.length; i++)
          {       
              con.innerHTML += "&lt;tr&gt;"+frame[i].textContent+"&lt;/tr&gt;&lt;hr&gt;";     
          }   
      }   
  }
  </code></pre>
  
  <p>The problem is frame.length is always 0 (online)<br/>
  offline the value has the right value.</p>
  
  <p>Can anyone help me?</p>