Re: Transfer javascript code from iFrame to a DIV
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Transfer javascript code from iFrame to a DIV

From: RobG <rgqld@iinet.net.au>
Date: Sat Apr 29 2006 - 14:04:20 CEST

bobzimuta wrote:
[...]
>
> Is the javascript inside the body of the IFRAME? To copy the contents
> completely as they are, I would use
> var content = test_iframe.document.body.cloneNode( true );
> document.getElementById("mainDiv").appendChild( content );

But 'content' will be a body element, putting a body element inside a
div may have serious implications. You should probably loop through the
child nodes of 'content' and add them to the div one by one:

   var content = test_iframe.document.body.cloneNode( true );
   var div = document.getElementById("mainDiv");

   while (content.firstChild) {
     div.appendChild(content.firstChild);
   }

-- 
Rob
Received on Mon May 1 05:26:51 2006