如何让 Delphi TWebbrowser 组件在 IE9 模式下运行? [英] How to have Delphi TWebbrowser component running in IE9 mode?

查看:43
本文介绍了如何让 Delphi TWebbrowser 组件在 IE9 模式下运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 TWebbrowser 在 IE7 兼容模式下运行,我在使用 TWebbrowser 时遇到 Javascript 错误.

有没有办法防止这种情况发生并让它在 IE9 模式下运行?

解决方案

  1. 选择使用使用记录的注册表项的浏览器模拟功能.
  2. 根据您选择的浏览器模拟设置,您可能需要确保您的文档包含合适的 DOCTYPE.同样,这在文档中有所描述.

因此,例如,如果您希望进行最简单的更改,您可以添加以下注册表设置:

<前>HKEY_LOCAL_MACHINE(或 HKEY_CURRENT_USER)软件微软IE浏览器主要的功能控制FEATURE_BROWSER_EMULATIONYourExeNameGoesHere.exe = (DWORD) 00009999

9999 的文档说:

<块引用>

9999 Windows Internet Explorer 9.无论 !DOCTYPE 指令如何,网页都以 IE9 标准模式显示.

如果您使用 9000 那么您还需要修改文档的 DOCTYPE:

<块引用>

9000 Internet Explorer 9.包含基于标准的 !DOCTYPE 指令的网页以 IE9 模式显示.Internet Explorer 9 的默认值.

链接的文档还包括指定其他 IE 版本所需的信息.

I am experiencing Javascript errors with TWebbrowser due to the fact that TWebbrowser is running in IE7 compatibility mode.

Is there a way to prevent this and just have it run in IE9 mode?

解决方案

  1. Opt in to the browser emulation feature using the documented registry key.
  2. Depending on the browser emulation setting that you selected, you may need to ensure that your document contains a suitable DOCTYPE. Again, this is described in the documentation.

So, for example, if you wish to make the simplest possible change you would add the following registry setting:

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
   SOFTWARE
      Microsoft
         Internet Explorer
            Main
               FeatureControl
                  FEATURE_BROWSER_EMULATION
                     YourExeNameGoesHere.exe = (DWORD) 00009999

The documentation for the value 9999 says:

9999 Windows Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.

Were you to use 9000 then you'd need also to modify the DOCTYPE of your document:

9000 Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.

The linked documentation also includes the information required to specify other IE versions.

这篇关于如何让 Delphi TWebbrowser 组件在 IE9 模式下运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆