FMX.WebBrowser.TWebBrowser
Delphi
TWebBrowser = class(TCustomWebBrowser)
C++
class PASCALIMPLEMENTATION TWebBrowser : public TCustomWebBrowser
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
class | public | FMX.WebBrowser.pas FMX.WebBrowser.hpp |
FMX.WebBrowser | FMX.WebBrowser |
Description
TWebBrowser defines a web browser.
TWebBrowser is a visual component that permits loading and displaying Web content or local files. The loaded URL or the name of the loaded file is specified through the URL property.
TWebBrowser offers support for the basic functions of a browser, such as: navigate to URL, go back, go forward, along with specific events.
To load and display content in TWebBrowser, call the Navigate method with the URL or file name as a parameter, or set the URL property, and then call the Navigate method without any parameters.
To load and display local files, explicitly deploy the file to be displayed by adding it to the Deployment Manager, and add the 'file://' string before the file name, when calling the Navigate method.
Example for loading a local file:
WebBrowser1.Navigate('file://MyFile.pdf')
Supporting JavaScript Integration on Windows Platform
On Windows target platforms (WIN32 and WIN64), TWebBrowser may incorrectly display some Web pages if a Web site uses JavaScript dialog boxes, panels, and other elements for various purposes.
To work around this issue, your application should display Web pages in the IE11 edge mode using the FEATURE_BROWSER_EMULATION feature of Internet Explorer.
To use this feature, make the appropriate changes to Windows Registry, as described in MSDN.
You can make appropriate changes manually by performing the following steps:
- Open the Registry Editor.
- Open the following key: HKEY_CURRENT_USER > Software > Microsoft > Internet Explorer > Main > FeatureControl > FEATURE_BROWSER_EMULATION.
- On the Edit menu, point to New, and then click DWORD (32-bit) Value.
- Set the name of this new entry to your executable file name, such as MyApps.exe.
- Select the newly created entry, and on the Edit menu, click Modify.
- In the Edit dialog box that opens, do the following:
- In the Value data text box, enter 11011.
- Under Base, select Decimal.
- Click OK to save your changes.
You can also cause your application to make the above described changes when the application starts. For example, in your project, the FormCreate event handler can call the following TForm1.SetPermissions method:
Delphi:
procedure TForm1.FormCreate(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
SetPermissions;
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
procedure TForm1.SetPermissions;
const
cHomePath = 'SOFTWARE';
cFeatureBrowserEmulation =
'Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\';
cIE11 = 11001;
var
Reg: TRegIniFile;
sKey: string;
begin
sKey := ExtractFileName(ParamStr(0));
Reg := TRegIniFile.Create(cHomePath);
try
if Reg.OpenKey(cFeatureBrowserEmulation, True) and
not(TRegistry(Reg).KeyExists(sKey) and (TRegistry(Reg).ReadInteger(sKey)
= cIE11)) then
TRegistry(Reg).WriteInteger(sKey, cIE11);
finally
Reg.Free;
end;
end;
{$ENDIF}
C++Builder:
void __fastcall TForm1::FormCreate(TObject *Sender) {
SetPermissions();
}
void __fastcall TForm1::SetPermissions() {
#ifdef _Windows
UnicodeString cHomePath = "SOFTWARE";
UnicodeString cFeatureBrowserEmulation =
"Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION\\";
int cIE11 = 11001;
UnicodeString sKey = ExtractFileName(ParamStr(0));
TRegIniFile *Reg = new TRegIniFile(cHomePath);
__try {
TRegistry *reg1 = dynamic_cast<TRegistry*>(Reg);
if (Reg->OpenKey(cFeatureBrowserEmulation,
true) && !(reg1->KeyExists(sKey) && reg1->ReadInteger(sKey)
== cIE11)) {
reg1->WriteInteger(sKey, cIE11);
}
}
__finally {
Reg->Free();
}
#endif
}