转载于(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,那么这个事件是忽略的。
本文介绍了一种在Webbrowser控件中禁用alert、confirm等弹窗的方法,通过在NavigateComplete2事件中执行特定脚本来实现。此方法在多数情况下有效,但在某些特殊场景下可能受限。

被折叠的 条评论
为什么被折叠?



