have you tried the IWebBrowser2::Silent Property?

解决方案 »

  1.   

    可以通过IHTMLScriptElement把alert删除,不过直接IWebBrowser2::put_Silent 也可。.
      

  2.   

    1. 用Silent不能禁止alert的弹出。
    2. 可以得到IHTMLScriptElement的时候,已经弹出来了,删得太晚了
       假如是按网页某一键才弹出的话是可以这样做,但是我的例子里写明的是立即弹出。
      

  3.   

    关注!
    得到IHTMLScriptElement的时候,已经弹出来了,删得太晚了
    另外,js报错提示如何禁止?
      

  4.   

    read this thread if you want to continue:http://groups.google.com/groups?hl=en&threadm=480101c0ee00%246b954810%24a4e62ecf%40tkmsftngxa06&rnum=1&prev=/groups%3Fq%3Dwebbrowser%2Bsuppress%2Balert%2Bmessage%2Bbox%26hl%3Den%26rnum%3D1%26selm%3D480101c0ee00%25246b954810%2524a4e62ecf%2540tkmsftngxa06
     The
    method is to override the javascript functions with stubs:function alert() {}
    function prompt() {}
    function confirm() {}The place to override these function is NavigateComplete2.
      

  5.   

    you just need to implement an OnError event handler in your code to prevent the error message boxes, see details at:
    http://support.microsoft.com/support/kb/articles/Q279/5/35.ASP
      

  6.   

    没用,他说在NavigateComplete2 Event时做这些事,可是收到NavigateComplete2 Event时警告框已经弹出来了!太晚了。
      

  7.   

    我查阅了MSDN, 记得它里面有这样的文章,是讲述宿主程序如何与内建的WebBrowser进行DHTML 对象事件对话的. 我想脚本也是一种对象,它也有相关的事件,好象是IHTMLScriptElement它的成员属性OnError(BOOL* Cancel) 当你不返回S_OK时是取消脚本运行出错的.具体的实现好象MSDN中也有相关资料 ,值得指出的时候,你必须是在OnBeforeNavigate()中取消建立的事件管道(Event Sink)否则正如楼上哥们所说无法控制.可以继续讨论.
      

  8.   

    是alert()函数弹出的框,不是脚本运行出错……