页面上两个位置的相同 iframe
Same iframe in two places on the page?
我有一个奇怪的问题。我已经在页面上创建了一个 iframe,现在想把它放在两个不同的支架中:
var iFrame = $('[data-id="loginWindowIframe"]');
//put the iframe in first holder
$('#loginWindow').html(iFrame);
//put the iframe to the second holder
$('[data-id="loginWindow"]').html(iFrame);
问题是,当我将其添加到第二个支架时,iframe 已从第一个支架中完全删除。似乎我只能在页面上有一个具有相同属性的 iframe 实例......
我做错了什么?
你只是在移动它。克隆它
var $iFrame = $('[data-id="loginWindowIframe"]');
//put the iframe in first holder
$('#loginWindow').empty().append($iFrame);
//put a clone of the iframe to the second holder
$('[data-id="loginWindow"]').empty().append($iFrame.clone());
请注意,我使用了$iFrame
而不是iFrame
。这纯粹是为了可读性 - 它表示它包含一个jQuery对象。
相关文章:
- 测试iFrame的位置.href是在jasmine单元测试中设置的
- 如何设置外部javascript创建的iframe的位置
- 获取相对于窗口的IFRAME位置
- 获取iframe中元素的Y位置
- 如果在iframe中,引导模式弹出将忽略滚动位置
- 在html中插入iframe的适当位置
- 刷新ul中在iframe中找到位置的元素
- 如何获得X&iframe中iframe的Y位置
- 如何使父网页从 iframe 滚动到特定位置(顶部)
- 根据用户光标的位置获取 iframe ID
- 同时加载 iframe 并重置文档位置
- 读取跨站点 iframe 位置
- 使 iframe/表单固定位置
- 如何定位“隐藏”的 iframe?(应用程序:链接到嵌入“隐藏的海报图像”嵌入的 Youtube 视频的起始位置)
- 完全使用 iframe 嵌入页面,没有边框,在边框曾经的位置没有空格
- Jquery 查看 iframe 位置是否已更改
- 窗口位置 阻止 iframe 重定向父窗口
- 鼠标位置在 iframe 上
- 防止 iframe 中的恶意 Flash 广告将用户重定向到顶部位置
- 如何将 iframe 位置内部重定向到另一个位置