[thelist] appendChild() invalid for frame?

SBeam sbeam at syxyz.net
Thu Jun 19 09:34:09 CDT 2003


On Thursday 19 June 2003 09:01 am, Peter-Paul Koch wrote:

> > var idoc = document.getElementById('theFrame').contentWindow.document;
> > idoc.body.appendChild(newNodes);
>
> Youre accessing the iframe incorrectly. Try frames[theFrame].document
> instead. See http://www.xs4all.nl/~ppk/js/index.html?iframe.html for more
> information.
>
> Of course it could always be that IE doesnt allow you to append children to
> an iframe at all. I dont know, I never tried it.
>

thanks, I hadn't thought of that - but it gives the same result. I did try 
setting the src of the iframe (since the spec requires it after all) and 
appending to that. Also tried using createTextNode() to make a simple node 
instead of cloneNode(). Also tried making a 'regular' frameset page and 
copying a node from frame1 to frame2. Apparently IE just won't let you 
manipulate the DOM between frames. I can't see any good reason for this 
except a bug or an overzealous security model (imagine that!)

as usual with these things, it is highly frustrating to the humble web 
developer. 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)? 

Sam


More information about the thelist mailing list