我已经像这样动态创建了 I 框架:
link = window.location.href;
var iframe = document.createElement('iframe');
iframe.setAttribute("src", link);
document.body.appendChild(iframe);
我的页面只是一个本地文件。我在那里有一个表格。我正在复制该表格
cloneNode(true);
并插入:
document.body.appendChild(newTable);
但在我的 Iframe 中,这个动态创建的表不存在。 那我该怎么办?
UPD:还有另一个问题,这在 chrome 中有效,但在 ie 和 firefox 中所有 Iframe 内容都是空的,只是空页面
UPD2:
我只是颠倒了 Iframe 并像这样创建它:
link = window.location.href;
var iframe = document.createElement('iframe');
iframe.setAttribute("src", link);
document.body.appendChild(iframe);
在 Ie 和 FF 中,它在 Iframe 中显示空白页面。
最佳答案
尝试importNode
而不是 appendChild
。
关于javascript - 使用相同的页面和动态创建的表创建 Iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20775140/