Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have Delphi TWebbrowser component running in IE9 mode?

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?

like image 765
user2638894 Avatar asked Sep 15 '14 08:09

user2638894


2 Answers

  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.

like image 84
David Heffernan Avatar answered Sep 24 '22 10:09

David Heffernan


include in html, " http-equiv="X-UA-Compatible" content="IE=edge"

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
</head>
<body> 
                your code ....
</body>
</html>
like image 22
Rafael Maires Rangel Avatar answered Sep 23 '22 10:09

Rafael Maires Rangel