0

我在加载某些网站时遇到脚本错误。

请帮助我如何防止 C# WebBrowser 中的脚本错误。

这是我的代码:

try
{
    webBrowser1.Navigate(textBox1.Text);
    while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
    {
        Application.DoEvents();
    }

    MessageBox.Show("Loaded");
}
catch(Exception)
{
    MessageBox.Show("failed");
}
4

5 回答 5

3

把它写在你的代码中

 webBrowser1.ScriptErrorsSuppressed = true;
于 2012-08-08T16:47:42.350 回答
1

要禁用脚本错误弹出,您需要转到(在 Internet Explorer 中)工具->Internet 选项,转到高级选项卡,然后在浏览中选择禁用脚本调试(其他),但是,问题可能与事实上,在 WebBrowser 控件中加载的每个站点都以 IE7 兼容模式呈现,要解决这个问题,您唯一能做的就是像这样的注册表黑客:WebBrowser control to use IE9

于 2012-08-08T16:52:32.933 回答
0

将您的注册表更改为 2af8,即 devenv.exe 软件/Microsoft/internet explorer/main/featurecontrol/feature_Browser_emulation 的 IE 11

于 2016-09-22T20:59:10.423 回答
0

很容易看出这个错误是如何消除的。但是 Visual Studio 使用 Internet Explorer 和另一个 Web 浏览器编码是困难的。如果您查看版本,最后一个 Visual Studio 使用 IE 11 for WebBrowser 工具。

建议将 C++ GUI 用于每种编码之一: https ://msdn.microsoft.com/en-us/library/60k1461a.aspx

于 2018-04-28T14:54:16.250 回答
0

如果您使用 GUI(如在 Visual Studio 中)只需转到 Webbrowser 属性并设置“ScriptErrorsSuppressed”= true

于 2017-02-20T12:34:44.583 回答