![](/img/trans.png)
[英]How to remove iframe from parent page using a function inside the iframe?
[英]How to remove the confirm dialog in iframe from parent page?
我有两个HTML页面。 说出parent.html和child.html。 child.html有一个确认对话框
confirm("Are you sure?");
如何从parent.html覆盖确认对话框?
<html>
<body>
<iframe id="iFrame" src="child.html"></iframe>
</body>
</html>
您可以进入iframe上下文并覆盖本机确认功能
var frames = document.getElementsByTagName('iframe');
frames[0].contentWindow.confirm = null;
注意:该函数在父作用域中仍然有效。
我认为这不是关闭/覆盖本机功能的最佳解决方案。 最好的办法是停止在子框架中调用确认函数的事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.