admin管理员组

文章数量:1313778

After opening an iframe, I sometimes need to close it. Thus far, I just remove the iframe from its parent node, thus cutting it off from the DOM. However, I'm finding that this doesn't immediately end the iframe's life, and its javascript code can still call back into the parent window, which no longer expects these callbacks.

How can I kill an iframe dead? I don't see a close or destroy method on it.

After opening an iframe, I sometimes need to close it. Thus far, I just remove the iframe from its parent node, thus cutting it off from the DOM. However, I'm finding that this doesn't immediately end the iframe's life, and its javascript code can still call back into the parent window, which no longer expects these callbacks.

How can I kill an iframe dead? I don't see a close or destroy method on it.

Share Improve this question asked Oct 26, 2009 at 17:56 Andrew ArnottAndrew Arnott 81.8k28 gold badges138 silver badges180 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

Create a blank.htm file on your site. Have the IFrame SRC set to the blank.htm, then remove the IFRAME.

if your using jQuery then you can use $.remove('iframe object id') method. This would remove the DOM object from the page and in this iframe would be removed.

try this..

<a href="Home.html" target="_parent">

本文标签: javascriptHow to close an iframeStack Overflow