How to remove iframe from parent page using function inside iframe?

I have an iframe that I put on the page using a bookmarklet, I want this iframe to close when I go to a specific page inside this iframe.

How to do it using JavaScript?

Note. The iframe and container page are in different domains.

+4
source share
4 answers

As far as I know, you cannot remove an element from the DOM from the iframe container if it is not the same domain, if I understand you correctly because of cross-domain security policies.

If it were possible, you could infiltrate banking sites and that’s all, it would be a mess.

+4
source

@meder iframe iframe?,

iframe .

UPDATE. , IE, : (

+3

- " " (http://en.wikipedia.org/wiki/Same_origin_policy)

,

jQuery('iframe-selector').remove(); // remove iframe
jQuery('iframe-selector').contents().empty(); // remove the iframe content
jQuery('iframe-selector').removeAttr('src'); // remove the source-attribute from the iframe
jQuery('iframe-selector').attr('src', 'javascript:return false;'); // remove the iframe source
+2

iframes.

0

All Articles