C# winform webbrowser如何指定内核为高版本

第一种方法,修改注册表

1)假设你应用程序的名字为MyApplication.exe:测试环境为vshost32.exe

2)运行Regedit,打开注册表,找到

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

3)添加以下项

 

IE各版本的值如下:

  • 11001 (0x2EDF) Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive

  • 11000 (0x2AF8) :Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode

  • 10000 (0x2710) :Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.

  • 10001 (0x2AF7) :Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.

  • 9999 (0x270F) :Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCT

  • YPE directive.

  • 9000 (0x2328) :Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.

  • 8888 (0x22B8) :Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.

  • 8000 (0x1F40) :Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.

  • 7000 (0x1B58) :Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.

第二种方法,直接代码赋值,我测试过,代码运行没有任何问题,代码如下:

  •  
  • const string BROWSER_EMULATION_KEY = @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
                //
                // app.exe and app.vshost.exe
                String appname = Process.GetCurrentProcess().ProcessName + ".exe";
                //
                // Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
                const int browserEmulationMode = 9999;

  •             RegistryKey browserEmulationKey =
                    Registry.CurrentUser.OpenSubKey(BROWSER_EMULATION_KEY, RegistryKeyPermissionCheck.ReadWriteSubTree) ??
                    Registry.CurrentUser.CreateSubKey(BROWSER_EMULATION_KEY);

  •             if (browserEmulationKey != null)
                {
                    browserEmulationKey.SetValue(appname, browserEmulationMode, RegistryValueKind.DWord);
                    browserEmulationKey.Close();
                }

猜你喜欢

转载自blog.csdn.net/qq165285727/article/details/80584506