With Windows Internet Explorer 8 or later the FEATURE_BROWSER_EMULATION feature defines the default emulation mode for Internet Explorer. Value 9999 - forces webpages to be displayed in IE9 Standards mode, regardless of the !DOCTYPE directive. You need IE9 or later installed on the target system. Check Internet Feature Controls (B..C)
private static void WebBrowserVersionEmulation()
{
const string BROWSER_EMULATION_KEY =
@"SoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_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();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…