Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move iframe along the DOM without losing it's content?

Is it possible?

I have tried to move it, but iframe contents dissapear.

Tried to get contents of iframe and place them in the new place but all handlers ofc dissapear.

Tried to do the same, but with new jQuery 1.4.2 feature, that clones all events along with it.

But it doesn't work :)

So I have decided to ask here for help.

How to move the damn iframe to another place in the document without losing it's contents? ^_^

Thanks

Added:

txtad_iframe = ad_container.find('iframe');                 
its_contents = txtad_iframe.contents();
its_body = its_contents.find("div:first").clone(true).insertAfter(cthis.find('#photos'));

Here i'm trying to copy contents to new ad container. But it doesn't work. Context banner doesn't react on click event.

I have tried to move ad_container to container, but iframe body content dissapears.

like image 852
Somebody Avatar asked May 21 '10 20:05

Somebody


1 Answers

I believe that items in an iframe aren't bound unless done so explicitly in that iframe. in other words, the iframe contents don't inherit the binding events from the parent window. you will have to bind first in the iframe and then move stuff around.

i think.

EDIT

I think you may want to do something like

its_body = its_contents.find("div:first").clone(true);
$(its_body).insertAfter(cthis.find('#photos'));
like image 127
Jason Avatar answered Oct 16 '22 11:10

Jason