vb.net 我可以将 WebBrowser 控件的渲染引擎更改为旧版本吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15412353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:47:45  来源:igfitidea点击:

Can I change the rendering engine of the WebBrowser control to an older version?

vb.netwinformsinternet-explorerinternet-explorer-9webbrowser-control

提问by sharkyenergy

i have an application with a webbrowsercontrol. this webbrowsercontrol is going to load a page that is not compatible with IE9. (cannot change this because its produced by somebody else) By default VB.NET 2010's webbrowser control uses IE9 renderengine, and can run in some sort of compatibility mode. unfortunately even in compatibility mode the page do not work. is there are way to use a webbrowser control with a genuine IE7 or IE8 render engine? thanks

我有一个带有 webbrowsercontrol 的应用程序。这个 webbrowsercontrol 将加载一个与 IE9 不兼容的页面。(无法更改,因为它是由其他人制作的)默认情况下,VB.NET 2010 的 webbrowser 控件使用 IE9 渲染引擎,并且可以在某种兼容模式下运行。不幸的是,即使在兼容模式下,页面也不工作。有没有办法在真正的 IE7 或 IE8 渲染引擎中使用 webbrowser 控件?谢谢

UPDATE

更新

explaining the problem: i have a page with a JAVA applet inside. this java applet has a popup opening with a textbox. this textbox is forced to stay in front until closed. this works fine in IE7 and IE8. in IE9 however if i move the browser window or access any other application this messagebox jumps to the back. and cant be clicked anymore. my webbrowser (IE9 running any emulation) does not work. it beheaves as if it still would be on IE9 even if i emulate IE7 or IE8.

解释问题:我有一个页面,里面有一个 JAVA 小程序。这个java小程序有一个带有文本框的弹出窗口。这个文本框被迫留在前面直到关闭。这在 IE7 和 IE8 中工作正常。但是,在 IE9 中,如果我移动浏览器窗口或访问任何其他应用程序,此消息框会跳到后面。并且不能再点击了。我的网络浏览器(运行任何仿真的 IE9)不工作。即使我模拟 IE7 或 IE8,它的行为也好像它仍然会在 IE9 上一样。

回答by Cody Gray

is there are way to use a webbrowser control with a genuine IE7 or IE8 render engine?

有没有办法在真正的 IE7 或 IE8 渲染引擎中使用 webbrowser 控件?

Yes, but it requires that you downgrade the version of Internet Explorer that is installed on the computer to version 7 or 8, which doesn't make for a friendly installation experience.

可以,但需要您将计算机上安装的 Internet Explorer 版本降级到版本 7 或 8,这不会带来友好的安装体验。

The issue is that the WebBrowser control always uses the version of IE that is installed on the computer because it simply delegates rendering to the native library shdocvw.dll, the same one that is used by IE itself. In your case, that appears to be IE 9. However, by default, it also runs in IE 7 compatibility mode. You can change this by editing the registry, but you cannot change the version of the rendering engine.

问题在于 WebBrowser 控件始终使用计算机上安装的 IE 版本,因为它只是将渲染委托给本机库 shdocvw.dll,与 IE 本身使用的库相同。在您的情况下,这似乎是 IE 9。但是,默认情况下,它也以 IE 7 兼容模式运行。您可以通过编辑注册表来更改此设置,但您无法更改渲染引擎的版本。

And unfortunately, this means you're out of luck, because running multiple versions of IE on a single computer is not and has never been a supported configuration. It can beaccomplishedfor testing purposes, but it requires additional software and the versions don't play nicely together. Certainly not nicely enough for one to support the standalone IE browser while the other drives the .NET WebBrowser control.

不幸的是,这意味着您不走运,因为在一台计算机上运行多个版本的 IE 从来都不是支持的配置。它可以完成测试的目的,但它需要额外的软件和版本不很好地一起玩。对于一个支持独立的 IE 浏览器而另一个驱动 .NET WebBrowser 控件来说,当然不够好。

Fixing the code to work properly with IE 9 is the best option. IE 9 represents Microsoft's slow progression towards a standards-compliant browser, and although it still has some quirks, it is worth supporting. I know you said that the website code is maintained by "someone else", but I recommend filing a support request with them—their code is buggy and needs to be fixed. If you (or they) need help with this, they can ask some of our code ninjasweb standards experts here on Stack Overflow.

修复代码以在 IE 9 中正常工作是最好的选择。IE 9 代表了微软向符合标准的浏览器的缓慢进展,虽然它仍然有一些怪癖,但值得支持。我知道你说过网站代码由“其他人”维护,但我建议向他们提交支持请求——他们的代码有问题,需要修复。如果您(或他们)需要这方面的帮助,他们可以在 Stack Overflow 上询问我们的一些代码忍者Web 标准专家。

Alternatively, you could explore replacing the WebBrowser control with an alternative control. There are several good ones for the .NET Framework, wrapping the rendering engines used by other popular browsers. For example:

或者,您可以探索用替代控件替换 WebBrowser 控件。.NET Framework 有几个很好的,包装了其他流行浏览器使用的渲染引擎。例如:

  • WebKit .NETis a wrapper for the WebKit engine, used by Google Chrome and Apple Safari.
  • GeckoFXis a wrapper for the Gecko rendering engine, used by Mozilla Firefox.
  • MozNetis an alternative wrapper for Gecko.
  • WebKit .NET是 Google Chrome 和 Apple Safari 使用的 WebKit 引擎的包装器。
  • GeckoFX是 Mozilla Firefox 使用的 Gecko 渲染引擎的包装器。
  • MozNet是 Gecko 的替代包装器。

Unfortunately, if the code you're dealing with is so badly written that IE 9's feeble attempt at standards-compliance brings it to its knees, it's unlikely that switching to the rendering engine for another even more standards-compliant browser will bring much success.

不幸的是,如果您正在处理的代码写得如此糟糕,以至于 IE 9 对标准合规性的微弱尝试使其屈服,那么切换到另一个更符合标准的浏览器的渲染引擎就不太可能取得成功。