[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 
><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>
>  function initFrame() {
>      var newNodes = document.getElementById('foo').cloneNode(true);
>      newNodes.style.display = 'block';
>      var idoc = 
>      idoc.body.appendChild(newNodes);
>  }
>This works fine in Mozilla. IE6 says "Invalid Argument" at the 
>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 

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
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
New: Forms, usability and the W3C DOM:

STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 

More information about the thelist mailing list