简体   繁体   中英

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. Any suggestions for IE? The button acutally exists on the iframe itself.

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

I don't know what "close" means with regard to an iframe other than removing it, so:

You can remove an iframe from the document using removeChild on its parent node, eg:

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. Ultimately it comes down to calling removeChild .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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