我正在尝试在控制台应用(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;
}