阻止WEBBROWSER访问时遇到window.alert

来源:互联网 发布:photoshop 2016 mac版 编辑:程序博客网 时间:2024/06/01 10:48

转载于(BlueDestiny前辈的BLOG):http://www.never-online.net/blog/article.asp?id=139

 Webbrowser本身变通的方法
如果你熟悉DHTML编程,应该知道IE中DHTML的属性和方法可以重写。当然alert,confirm, showModalDialog也不例外。
解决方法就是在NavigateComplete2事件中加入代码

pDisp.Document.parentWindow.execScript "window.alert=null;"
pDisp.Document.parentWindow.execScript "window.confirm=null;"
pDisp.Document.parentWindow.execScript "window.showModalDialog=null;"
pDisp.Document.parentWindow.execScript "window.open=null;"

 

注意:这是制标不制本的,只是在大多数时候有效,失效的时候比如:当提效数据之后返回响应中有alert,那么这个事件是忽略的。

原创粉丝点击