windows IWebBrowser2 对象使用 IE7 版本,而不是机器上安装的 IE 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6914664/
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-15 17:40:27  来源:igfitidea点击:

IWebBrowser2 object uses IE7 version, instead of the IE version installed on the machine

windowsinternet-exploreriwebbrowser2

提问by Bagelzone Ha'bonè

I'm developing on a Win7 machine with IE8 browser (same thing occurs also on IE9).

我正在使用 IE8 浏览器的 Win7 机器上开发(同样的事情也发生在 IE9 上)。

I've create an application with an IWebBrowser2object embedded within a native window.
Within that browser object i execute a javascipt code:

我创建了一个应用程序,其中IWebBrowser2对象嵌入在本机窗口中。
在该浏览器对象中,我执行一个 javascipt 代码:

  var txt = "Browser Name: " + navigator.appName + "\n";
  txt += "Browser Version: " + navigator.appVersion + "\n";
  alert(txt);

and i receive the following alert: enter image description here

我收到以下警报: 在此处输入图片说明

That confirmed my earlier worries - even when having IE8\IE9 installed on my machine - the IWebBrowser2object behaves as if it was IE7(including all of the annoying HTML\CSS behaviors).

这证实了我之前的担忧——即使我的机器上安装了 IE8\IE9—— IWebBrowser2对象的行为就像是IE7(包括所有烦人的 HTML\CSS 行为)。

Does anyone know why this is? or better - if there is any possibility to embed a browser object as IE8\IE9 (for distribution - so it should be legal)

有人知道为什么是这样吗?或者更好 - 如果有可能将浏览器对象嵌入为 IE8\IE9(用于分发 - 所以它应该是合法的)

Thanks,

谢谢,

回答by Heinrich Ulbricht

IE7 is the default rendering mode for embedded IE controls (for compatibility reasons). Use the FEATURE_BROWSER_EMULATIONregistry key to change that.

IE7 是嵌入式 IE 控件的默认呈现模式(出于兼容性原因)。使用FEATURE_BROWSER_EMULATION注册表项来更改它。

Read Plip's answer over hereor IEBlogto get an idea how to do this.

在此处阅读Plip 的回答IEBlog以了解如何执行此操作。