javascript - 在 IE 中使用 Javascript 关闭 Iframe

标签 javascript html iframe

我正在尝试关闭 Iframe,下面的内容适用于除 IE7 和 IE8 之外的所有浏览器。对IE有什么建议吗?该按钮实际上存在于 iframe 本身上。

<input type="submit" onclick="history.go(0)"

最佳答案

除了删除它之外,我不知道“关闭”对于 iframe 意味着什么,所以:

您可以在其父节点上使用 removeChild 从文档中删除 iframe,例如:

var iframe = window.parent.document.getElementById('theIframe');
iframe.parentNode.removeChild(iframe);

Live example

我使用 id 在父窗口中查找 iframe 元素,但显然您有很多选择来查找它。最终归结为调用 removeChild .

关于javascript - 在 IE 中使用 Javascript 关闭 Iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5548675/

相关文章:

javascript - jquery ui 按钮没有样式

javascript - 在 .map 函数中使用 react Prop

java - GWT "database"(客户端)

html - 删除点击按钮周围的边框

html - flexbox 元素中的白线不会消失

javascript - 触发 iframe 上的点击不起作用

javascript - 如何让 iframe 保持其位置?

javascript - Knockout 的 HTML 绑定(bind) + SVG

javascript - Magnific Popup iframe 高度和宽度

c# - 多行标签与低 DIV 合并