WinForm
webBrowser
中嵌入网页。运行操作网页中的iframe..但运行多了就会出现脚本错误,
问一下怎么样屏蔽这种脚本错误,继续执行操作网页。
webBrowser
中嵌入网页。运行操作网页中的iframe..但运行多了就会出现脚本错误,
问一下怎么样屏蔽这种脚本错误,继续执行操作网页。
解决方案
10
webBrowser1.ScriptErrorsSuppressed = true
20
webBrowser1.ScriptErrorsSuppressed = true(据说在.net framework2.0以前是这样)
.net framework2.0以上版本,有一种不是很好的解决方法。
//捕获控件的错误
this.WebBrowser.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error);
//对错误进行处理
void Window_Error(object sender, HtmlElementErrorEventArgs e)
{
// 本人的处理代码
e.Handled = true;
}
.net framework2.0以上版本,有一种不是很好的解决方法。
//捕获控件的错误
this.WebBrowser.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error);
//对错误进行处理
void Window_Error(object sender, HtmlElementErrorEventArgs e)
{
// 本人的处理代码
e.Handled = true;
}
10
int AxWebBrowserIDocHostUi.OleInterfaces.IDocHostShowUI.ShowMessage(IntPtr hwnd, string lpstrText, string lpstrCaption, uint dwType, string lpstrHelpFile, uint dwHelpContext, ref int lpResult)
{
lpResult = 0;
if (lpstrText == "Hello222222")
{
if (MessageBox.Show("能否要屏蔽Alert对话框", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
MessageBox.Show("屏蔽鸟", "屏蔽鸟");
return Hresults.S_OK;
}
else
{
//
}
}