aa**********@yahoo.com wrote:
Hi folks
I've googled for an answer to this, with no success. Can someone please
jump in, and put me out of my misery! (I'm sure it's quite simple)
I have an invisible IFRAME, and a visible DIV:
<IFRAME id=myframe style="display:none" src="..."
onload="ShowNews(this)"></IFRAME>
<DIV id=mydiv></DIV>
I need to copy the content from the IFRAME, into the DIV. Everything
comes from the same domain, so there are definitely not any
cross-domain security issues.
This works fine in IE6:
function ShowNews(x) {
document.all.mydiv.innerHTML =
x.contentWindow.document.body.outerHTML
}
but in Firefox 1.5 it fails with the error,
"x.contentWindow.document.body has no properties".
I've tried various changes, with no success.
How can I recode that statement, so it works in either browser?
TIA,
TC (MVP MSAccess)
http://tc2.atspace.com
I don't know if this helps, but I've done something like this:
I've put a div tag inside the IFrame document and a small javascript
snippet at the end that takes the innerHTML from the div and sends it
to the parent window.
"index.html":
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
var global_variable_1 = "<p>No page found</p>";
function make_global(variable_a)
{
global_variable_1 = variable_a;
}
function present_site()
{
document.getElementById("where_to_put_loaded_page" ).innerHTML =
global_variable_1;
}
//-->
</script>
</head>
<body onload="present_site()">
[...]
<div id="where_to_put_loaded_page">
Initial text here is: no page loaded.
</div>
<iframe style="visibility: hidden" src="page1.html"></iframe>
</body>
</html>
"page1.html" (loaded page):
<html>
<body>
[...]
<div id="meaningful_content">
Here I put the content that I want dynamically loaded in the main page.
</div>
[...]
<script language="javascript" type="text/javascript">
<!--
this.parent.make_global(document.getElementById("m eaningful_content").innerHTML);
//-->
</script>
</body>
</html>
So basically I send the content from the IFrame to the main page via a
global variable and take/replace it via innerHTML. The only problem
with this is
that the iframe css doesn't get "shipped" to the main page. I've
temporarily solved that
by inlining the css, but if you find a better way, please tell me.