Somebody
Somebody

Reputation: 9645

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.

Upvotes: 6

Views: 4265

Answers (1)

Jason
Jason

Reputation: 52523

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'));

Upvotes: 1

Related Questions