My problem is as follows:
I designed a homepage and I Have a index (www.abc.com) site and a site with news(www.abc.com/index.html).
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.
The way I'm doing this is:
- Include an iframe (www.abc.com/index.html) in my index
- iframe is not visible
- Getting the structure of the iframe in my JS
- Picking out the information I need for the index
- Copy the data into my index
I know that I can't get data out from iframes which are not in my webspace, but this is in my webspace.
<iframe name="nf" id="newsframe" src="http://www.rossegger.at/news.html"
style="visibility:hidden"></iframe>
<table id="news_table"></table>
function load_news() {
var con = document.getElementById("news_table");
var frame = window.frames['nf'].document.getElementsByClassName('n');
if(frame.length != 0)
{
con.innerHTML += "<tr><h2 color=white>NEWS</h2></tr><hr>";
for(var i=0; i<frame.length; i++)
{
con.innerHTML += "<tr>"+frame[i].textContent+"</tr><hr>";
}
}
}
The problem is frame.length is always 0 (online)
offline the value has the right value.
Can anyone help me?