如何禁用对话框 - alert()? [英] How to disable dialog boxes - alert()?

查看:264
本文介绍了如何禁用对话框 - alert()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我正在显示iframe的页面。 iframe与网站在同一个域中,因此我可以编辑和阅读它的内容,但我无法编辑iframe的源代码,因为我无法访问该文件本身。
iframe警告消息,我想禁用它。
我想至少为自己禁用对话框,我正在使用chrome ...

I have a page where I'm displaying iframes. The iframes are on the same domain with the website so I can edit and read the content of it, but I can't edit the source code of the iframes, because I don't have access to the file itself. The iframes are alerting a message and I want to disable this. I want to disable the dialog boxes at least for myself, I`m using chrome...

这是否可以在不禁用javascript的情况下实现?
或者我可以在iframe中禁用javascript吗?

Is this possible without disabling javascript ? Or could I disable javascript only inside the iframes ?

推荐答案

怎么样:

window.frames[0].alert = function() {};

它用一个什么都不做的函数覆盖第一个iframe中的alert函数,因此全部 alert(...)在那里调用的调用没有任何结果。

It overwrites the alert function inside the first iframe with a function that does nothing, hence all alert(...) calls called there result in nothing happening.

至于后续的iframe,你需要改变 0 进入 1 等。

As for subsequent iframes, you'd need to change 0 into 1 etc.

这篇关于如何禁用对话框 - alert()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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