如何使用iframe中的函数从父页面中删除iframe? [英] How to remove iframe from parent page using a function inside the iframe?

查看:161
本文介绍了如何使用iframe中的函数从父页面中删除iframe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用bookmarklet放在页面上的iframe,当我导航到此iframe中的某个页面时,我希望此iframe自动关闭。



使用JavaScript做到这一点?



注意:iframe和容器页面位于不同的域中。

解决方案

据我所知,除非它是相同的域,否则无法从iframe的容器中移除DOM中的元素,因为跨域安全策略可以正确理解您。
$ b

如果可能的话,您可以渗透到银行网站和所有的网站,这会很糟糕。


I have an iframe I put on a page using a bookmarklet, I want this iframe to close itself when I navigate to a certain page inside this iframe.

How to do that using JavaScript?

Note: iframe and container page are in different domains.

解决方案

As far as I know you cannot remove the element from the DOM from the iframe's container unless it's the same domain if I'm understanding you properly due to cross-domain security policies.

If this were possible you could infiltrate bank sites and all, it'd be a mess.

这篇关于如何使用iframe中的函数从父页面中删除iframe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆