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: bobzimuta <ejmalone@gmail.com>
Date: Sat Apr 29 2006 - 01:50:41 CEST

sameergn@gmail.com wrote:
> Hi,
>
> I have HTML form whose target is an invisible IFrame. After the IFrame
> is loaded completely,
> following code transfers contents of IFrame to DIV
>
> document.getElementById("mainDiv").innerHTML =
> test_iframe.document.body.innerHTML;
>
> but this does not seem to carry over the Javascript code from IFrame to
> DIV.
> Can anyone comment if this is the correct behavior or a bug?
> (The requirement is to submit a form and update only portion of screen,
> without using
> AJAX. A DIV cannot be target of the FORM, hence the IFrame->DIV route)
>
> Thanks,
> Sameer

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 );
Received on Mon May 1 05:26:29 2006