【发布时间】:2018-04-09 02:33:37
【问题描述】:
【问题讨论】:
标签: c# wpf winforms webbrowser-control
【问题讨论】:
标签: c# wpf winforms webbrowser-control
我知道这个问题发布已经很久了,但我找到了一个适合我的解决方案。
// Hides script errors without hiding other dialog boxes.
private void SuppressScriptErrorsOnly(WebBrowser browser)
{
// Ensure that ScriptErrorsSuppressed is set to false.
browser.ScriptErrorsSuppressed = false;
// Handle DocumentCompleted to gain access to the Document object.
browser.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(
browser_DocumentCompleted);
}
private void browser_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
((WebBrowser)sender).Document.Window.Error +=
new HtmlElementErrorEventHandler(Window_Error);
}
private void Window_Error(object sender,
HtmlElementErrorEventArgs e)
{
// Ignore the error and suppress the error dialog box.
e.Handled = true;
}
您还可以检查错误的行号/ url 以抑制一些错误。
如果错误描述是要标记为已处理的语法错误。
-- 也关于升级到最新版本/新版本 - 我正在处理的网站需要是 IE。
【讨论】: