捕获 javascript 弹出窗口 [英] Capturing javascript popups

查看:28
本文介绍了捕获 javascript 弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WebBrowser中,有没有办法捕获javascript生成的愚蠢弹出窗口?

In WebBrowser, is there anyway to capture the stupid popups that are generated by javascript?

那些说成功"或者说成功"并有确定"按钮的人.

The ones which say "Success" or watever and have the "Ok" button.

我尝试了 WebBrowserNewWindow"事件,但没有触发.

I tried the WebBrowser "NewWindow" event, but this is not being fired.

有什么建议吗?

推荐答案

您可以简单地重新定义全局 javascript 警报功能,如下所示:

You could simply redefine the global javascript alert function like this:

function alert() {}

那么当其他代码调用警报时什么也不会发生.

then nothing will happen when other code calls the alert.

更新:

要做到这一点,请将以下内容添加到您的页面代码中:

to do this add the following to your page code:

<script>
   function alert() {}
</script>

如果你将它注入你的页面,那么你可能希望查看greasemonkey,然后使用它添加这个脚本:

If you are injecting it to your pages then you may wish to look at greasemonkey and then add this script using that:

https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

所有浏览器都有类似的插件.

there are similar addons for all browsers.

这篇关于捕获 javascript 弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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