Winform浏览器显示脚本错误,但IE不显示

时间:2017-06-28 13:37:32

标签: javascript wpf webbrowser-control

我在WPF应用程序中使用Winform Broswer控件的代码片段如下:

private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)  
{
   var host = new System.Windows.Forms.Integration.WindowsFormsHost();
   host.Child = webTest;
   this.SampleGrid.Children.Add(host);
   webTest.Navigate("https://www.merckmanuals.com/professional/cardiovascular-disorders/symptoms-of-cardiovascular-disorders/limb-pain?media=print");
}

如果我使用任何其他链接,例如 http://www.google.com它运作正常。

但是这个链接https://www.merckmanuals.com/professional/cardiovascular-disorders/symptoms-of-cardiovascular-disorders/limb-pain?media=print 当我试图在浏览器控件中显示它时出现javascript错误。

使用IE时,相同的链接正常工作。

据我所知,WebBrowser控件使用IE中的dll,因此可以使用Web打开的东西也可以使用WebBrowser控件打开。

我尝试使用

webTest.ScriptErrorsSuppressed = true;

但是这只是显示空白页而没有任何脚本错误。

我甚至试过使用WPF webbrowser控件,但没有运气:(

有人可以建议解决这个问题的方法吗?

1 个答案:

答案 0 :(得分:0)

可能是由浏览器控件使用的错误版IE引擎造成的。

尝试为您的应用程序设置正确的注册表项可能会有更新版本的IE处理。默认情况下,WebBrowser控件使用IE 7.0引擎。

这是一个很长的描述如何实现:

https://weblog.west-wind.com/posts/2011/may/21/web-browser-control-specifying-the-ie-version

希望它能够解决问题