简体   繁体   English

在IE中使用JavaScript关闭iframe

[英]Closing Iframe with Javascript in IE

I'm trying to close a Iframe and the below works for every browser except for IE7 an IE8. 我正在尝试关闭iframe,以下内容适用于除IE7和IE8之外的所有浏览器。 Any suggestions for IE? 对IE有什么建议吗? The button acutally exists on the iframe itself. 该按钮实际上存在于iframe本身上。

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

I don't know what "close" means with regard to an iframe other than removing it, so: 除了删除iframe我不知道“关闭”是什么意思,所以:

You can remove an iframe from the document using removeChild on its parent node, eg: 您可以在其父节点上使用removeChild从文档中删除iframe ,例如:

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

Live example 现场例子

There I'm using an id to find the iframe element in the parent window, but obviously you have lots of choices for how to find it. 我在其中使用id在父窗口中查找iframe元素,但是显然,您有很多选择方法来查找它。 Ultimately it comes down to calling removeChild . 最终归结为调用removeChild

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM