[thelist] appendChild() invalid for frame?

Peter-Paul Koch gassinaumasis at hotmail.com
Thu Jun 19 08:01:38 CDT 2003


>In trying to use the DOM to perform some acrobatics for a CMS, using
>cloneNode() and appendNode() to try to copy some default XHTML into a 
>IFRAME:
>
><html> <body onload="initFrame()">
><div id="foo" style="display: none">this is some <em>foo</em> for you</div>
><iframe id="theFrame" width="310" height="100"></iframe>
><script>
>  function initFrame() {
>      var newNodes = document.getElementById('foo').cloneNode(true);
>      newNodes.style.display = 'block';
>      var idoc = 
>document.getElementById('theFrame').contentWindow.document;
>      idoc.body.appendChild(newNodes);
>  }
></script>
></body></html>
>
>This works fine in Mozilla. IE6 says "Invalid Argument" at the 
>appendChild()
>line. Have tried many permutations of replaceChild(), insertBefore(), etc.
>with the same result. It does work if the node I am appending to is in the
>same document (not in a separate frame)...

You´re 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 doesn´t allow you to append children to 
an iframe at all. I don´t know, I never tried it.

-------------------------------------------------------------------
ppk, freelance web developer
Interactie, copywriting, JavaScript, integration
http://www.xs4all.nl/~ppk/
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
New: Forms, usability and the W3C DOM:
http://digital-web.com/features/feature_2003-05b.shtml
------------------------------------------------------------------

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail



More information about the thelist mailing list