0

我正在尝试在控制台应用程序(dll)上使用 webbrowser 控件

我想阻止它打开新窗口。

using (WebBrowser wb = new WebBrowser())
    {

                    wb.ScrollBarsEnabled = false;
                    wb.ScriptErrorsSuppressed = true;
           wb.NewWindow += new System.ComponentModel.CancelEventHandler(wb_NewWindow);        
                   wb.Navigate(url);
            while (wb.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }
  }



private void wb_NewWindow(object sender, CancelEventArgs e)
        {
            //System.Windows.Forms.HtmlDocument document =
            //    this.webBrowser1.Document;

                       e.Cancel = true; 

        }
4

0 回答 0