如何在DOM中移动iframe而不会丢失内容? [英] How to move iframe along the DOM without losing it's content?

查看:93
本文介绍了如何在DOM中移动iframe而不会丢失内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以吗?

我尝试移动它,但是iframe内容消失。

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

获取iframe的内容,并将它们放在新的位置,但是所有的处理程序都会消失。

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

试图做同样的事情,但是使用新的jQuery 1.4.2功能,克隆所有事件一起。

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

但它不工作:)

所以我决定问在这里寻求帮助。

So I have decided to ask here for help.

如何将该死的iframe移动到文档中的另一个位置,而不会丢失其内容? ^ _ ^

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

谢谢

添加:

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.

我试图将ad_container移动到容器,但是iframe正文内容消失。

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

推荐答案

我认为,iframe中的项目不受约束,除非在该iframe中明确指定。换句话说,iframe内容不会从父窗口继承绑定事件。你必须首先绑定在iframe中,然后移动东西。

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.

我想。

编辑

我想你可能想做一些像

its_body = its_contents.find("div:first").clone(true);
$(its_body).insertAfter(cthis.find('#photos'));

这篇关于如何在DOM中移动iframe而不会丢失内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆