[thelist] appendChild() invalid for frame?
SBeam
sbeam at syxyz.net
Thu Jun 19 15:33:07 CDT 2003
On Thursday 19 June 2003 11:12 am, Daniel Frey wrote:
> >Does anyone know a way to dynamically assign a chunk of HTML to an
> >IFRAME (can't use src or document.location because there is no such thing
> > in this case)?
>
> I remember doing something like this in the past, I wanted users to be able
> to open a page for editing (the editing all took place in an iframe) - the
> solution I came up with (although I'm certain not the world's best) was to
> have a hidden div do all the work. I would clear out the div, and using a
> little ASP, open the file within the hidden div. Then, I'd do a
> document.write to the iframe using the innerHTML of the div. Again, not
> the ideal solution, but it worked very well for the situation.
>
Thanks! my original version actually used innerHTML but I thought it was
broken for various reasons, so I tried appendChild(), which won't work in
IE... So your post got me backtracking, fixed up the original, and here it is
for posterity's sake:
<html> <body onload="initFrame()">
<div id="foo" style="display: none">this is some <b>foo</b> for you</div>
<iframe id="theFrame" width="310" height="100" ></iframe>
<script>
function initFrame() {
var defval = document.getElementById('foo').innerHTML;
var iDoc = document.getElementById('theFrame').contentWindow.document;
iDoc.body.innerHTML = defval;
}
</script>
</body> </html>
now I am on to bigger and uglier problems... thanks to all who replied.
More information about the thelist
mailing list