use*_*894 13 delphi twebbrowser
由于TWebbrowser在IE7兼容模式下运行,我遇到了TWebbrowser的Javascript错误.
有没有办法防止这种情况,只是让它在IE9模式下运行?
Dav*_*nan 11
因此,例如,如果您希望进行最简单的更改,则需要添加以下注册表设置:
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
SOFTWARE
Microsoft
Internet Explorer
Main
FeatureControl
FEATURE_BROWSER_EMULATION
YourExeNameGoesHere.exe = (DWORD) 00009999
该值的文档9999说:
9999 Windows Internet Explorer 9.网页以IE9标准模式显示,与!DOCTYPE指令无关.
如果您要使用,9000那么您还需要修改文档的DOCTYPE:
9000 Internet Explorer 9.包含基于标准的网页!DOCTYPE指令以IE9模式显示.Internet Explorer 9的默认值.
链接的文档还包括指定其他IE版本所需的信息.
小智 5
包含在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>
Run Code Online (Sandbox Code Playgroud)
将此类添加到您的代码中:
type TBrowserEmulationAdjuster = class
private
class function GetExeName(): String; inline;
public const
// Quelle: https://msdn.microsoft.com/library/ee330730.aspx, Stand: 2017-04-26
IE11_default = 11000;
IE11_Quirks = 11001;
IE10_force = 10001;
IE10_default = 10000;
IE9_Quirks = 9999;
IE9_default = 9000;
/// <summary>
/// Webpages containing standards-based !DOCTYPE directives are displayed in IE7
/// Standards mode. Default value for applications hosting the WebBrowser Control.
/// </summary>
IE7_embedded = 7000;
public
class procedure SetBrowserEmulationDWORD(const value: DWORD);
end platform;
Run Code Online (Sandbox Code Playgroud)
class function TBrowserEmulationAdjuster.GetExeName(): String;
begin
Result := TPath.GetFileName( ParamStr(0) );
end;
class procedure TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(const value: DWORD);
const registryPath = 'Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION';
var
registry: TRegistry;
exeName: String;
begin
exeName := GetExeName();
registry := TRegistry.Create(KEY_SET_VALUE);
try
registry.RootKey := HKEY_CURRENT_USER;
Win32Check( registry.OpenKey(registryPath, True) );
registry.WriteInteger(exeName, value)
finally
registry.Destroy();
end;
Run Code Online (Sandbox Code Playgroud)
结尾;
然后添加到表单的 OnCreate 中:
TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(TBrowserEmulationAdjuster.IE11_Quirks);
Run Code Online (Sandbox Code Playgroud)
那是永远