C# Windows Forms应用程序中webbrowser控件的默认版本是7。我已经在文章中将其更改为9,但是如何在webbrowser控件中使用已安装的Internet Explorer的最新版本?
发布于 2015-12-14 20:31:08
使用来自MSDN的值
int BrowserVer, RegVal;
// get the installed IE version
using (WebBrowser Wb = new WebBrowser())
BrowserVer = Wb.Version.Major;
// set the appropriate IE version
if (BrowserVer >= 11)
RegVal = 11001;
else if (BrowserVer == 10)
RegVal = 10001;
else if (BrowserVer == 9)
RegVal = 9999;
else if (BrowserVer == 8)
RegVal = 8888;
else
RegVal = 7000;
// set the actual key
using (RegistryKey Key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree))
if (Key.GetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe") == null)
Key.SetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe", RegVal, RegistryValueKind.DWord);
发布于 2016-09-16 22:40:23
我不需要更改RegKey,而是可以在我的HTML头中放一行:
<html>
<head>
<!-- Use lastest version of Internet Explorer -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Insert other header tags here -->
</head>
...
</html>
参见。
发布于 2013-07-29 19:09:49
你可以试试这个link
try
{
var IEVAlue = 9000; // can be: 9999 , 9000, 8888, 8000, 7000
var targetApplication = Processes.getCurrentProcessName() + ".exe";
var localMachine = Registry.LocalMachine;
var parentKeyLocation = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl";
var keyName = "FEATURE_BROWSER_EMULATION";
"opening up Key: {0} at {1}".info(keyName, parentKeyLocation);
var subKey = localMachine.getOrCreateSubKey(parentKeyLocation,keyName,true);
subKey.SetValue(targetApplication, IEVAlue,RegistryValueKind.DWord);
return "all done, now try it on a new process".info();
}
catch(Exception ex)
{
ex.log();
"NOTE: you need to run this under no UAC".info();
}
https://stackoverflow.com/questions/17922308
复制相似问题