Blocking dialogs in .NET WebBrowser control

前端 未结 12 1283
执笔经年
执笔经年 2020-11-27 17:04

I have a .NET 2.0 WebBrowser control used to navigate some pages with no user interaction (don\'t ask...long story). Because of the user-less nature of thi

12条回答
  •  萌比男神i
    2020-11-27 17:24

    The easiest way to do this is : In the : Webbrowser Control you have the procedure ( standard ) BeforeScriptExecute

    ( The parameter for BeforeScriptExecute is pdispwindow )

    Add this :

    pdispwindow.execscript("window.alert = function () { }")
    

    In this way before any script execution on the page window alert will be suppressed by injected code.

提交回复
热议问题