Sign in Join
Wiki copytemporary

Webbrowser: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-This page summarizes various ways to display HTML pages from a Pascal program, ranging from calling an external browser to adding a component capable of rendering the html page into a form.
1+This page summarizes various ways to display HTML pages from a Pascal program, ranging from calling an external browser to adding a component capable of rendering the html page into a form.
22
33## Starting a web browser to show a page/URL
44
55### OpenURL
66
7-OpenURL is simplest way of opening URLs in general. This procedure will detect the default web browser and open URL from parameter in it. It can be used for mail addresses of the form 'mailto:aname@AnAddress?subject=:::A subject line', web addresses 'http://' and files 'file:///'.
8-
9-``` pascal
7+OpenURL is simplest way of opening URLs in general. This procedure will detect the default web browser and open URL from parameter in it. It can be used for mail addresses of the form 'mailto:aname@AnAddress?subject=:::A subject line', web addresses 'http://' and files 'file:///'.
8+```
109uses LCLIntf;
11-...
12-OpenURL('http://www.lazarus.freepascal.org');
10+ ...
11+ OpenURL('http://www.lazarus.freepascal.org');
1312```
1413
1514### Finding the default web browser
1615
17-Every platform has a mechanism for its default web browser. The LCL unit **lazhelphtml** contains a class [[THTMLBrowserHelpViewer]] to start a web browser for the LCL help system.
18-
19-You can use its method FindDefaultBrowser to find the default browser and the parameter to start. For example:
16+Every platform has a mechanism for its default web browser. The LCL unit **lazhelphtml** contains a class [[THTMLBrowserHelpViewer]] to start a web browser for the LCL help system.
2017
21-``` pascal
18+You can use its method FindDefaultBrowser to find the default browser and the parameter to start. For example:
19+```
2220uses
23- Classes, ..., LCLProc, LazHelpHTML;
24-
25-...
26-
27-implementation
28-
29-procedure TMainForm.Button1Click(Sender: TObject);
30-var
31- v: THTMLBrowserHelpViewer;
32- BrowserPath, BrowserParams: string;
33-begin
34- v:=THTMLBrowserHelpViewer.Create(nil);
35- v.FindDefaultBrowser(BrowserPath,BrowserParams);
36- debugln('Browser=',BrowserPath,' Params=',BrowserParams);
37- v.Free;
38-end;
21+ Classes, ..., LCLProc, LazHelpHTML;
22+
23+ ...
24+
25+ implementation
26+
27+ procedure TMainForm.Button1Click(Sender: TObject);
28+ var
29+ v: THTMLBrowserHelpViewer;
30+ BrowserPath, BrowserParams: string;
31+ begin
32+ v:=THTMLBrowserHelpViewer.Create(nil);
33+ v.FindDefaultBrowser(BrowserPath,BrowserParams);
34+ debugln('Browser=',BrowserPath,' Params=',BrowserParams);
35+ v.Free;
36+ end;
3937```
4038
41-This gives for example under Ubuntu (Linux):
42-
43-```text
39+This gives for example under Ubuntu (Linux):
40+```
4441Browser=/usr/bin/xdg-open Params=%s
4542```
4643
47-Under Windows:
48-
49-```text
44+Under Windows:
45+```
5046Browser=C:\windows\system32\rundll32.exe Params=url.dll,FileProtocolHandler %s
5147```
5248
53-Under macOS:
54-
55-```text
49+Under macOS:
50+```
5651Browser=/usr/bin/open Params="%s"
5752```
5853
5954### Starting the browser
6055
61-Once you know the command line and parameters you can use [[TProcessUTF8]] to start the browser:
62-
63-``` pascal
56+Once you know the command line and parameters you can use [[TProcessUTF8]] to start the browser:
57+```
6458uses
65- Classes, ..., LCLProc, LazHelpHTML, UTF8Process;
66-
67-...
68-
69-implementation
70-
71-procedure TMainForm.Button1Click(Sender: TObject);
72-var
73- v: THTMLBrowserHelpViewer;
74- BrowserPath, BrowserParams: string;
75- p: LongInt;
76- URL: String;
77- BrowserProcess: TProcessUTF8;
78-begin
79- v:=THTMLBrowserHelpViewer.Create(nil);
80- try
81- v.FindDefaultBrowser(BrowserPath,BrowserParams);
82- debugln(['Path=',BrowserPath,' Params=',BrowserParams]);
83-
84- URL:='http://www.lazarus.freepascal.org';
85- p:=System.Pos('%s', BrowserParams);
86- System.Delete(BrowserParams,p,2);
87- System.Insert(URL,BrowserParams,p);
88-
89- // start browser
90- BrowserProcess:=TProcessUTF8.Create(nil);
91- try
92- BrowserProcess.CommandLine:=BrowserPath+' '+BrowserParams;
93- BrowserProcess.Execute;
94- finally
95- BrowserProcess.Free;
59+ Classes, ..., LCLProc, LazHelpHTML, UTF8Process;
60+
61+ ...
62+
63+ implementation
64+
65+ procedure TMainForm.Button1Click(Sender: TObject);
66+ var
67+ v: THTMLBrowserHelpViewer;
68+ BrowserPath, BrowserParams: string;
69+ p: LongInt;
70+ URL: String;
71+ BrowserProcess: TProcessUTF8;
72+ begin
73+ v:=THTMLBrowserHelpViewer.Create(nil);
74+ try
75+ v.FindDefaultBrowser(BrowserPath,BrowserParams);
76+ debugln(['Path=',BrowserPath,' Params=',BrowserParams]);
77+
78+ URL:='http://www.lazarus.freepascal.org';
79+ p:=System.Pos('%s', BrowserParams);
80+ System.Delete(BrowserParams,p,2);
81+ System.Insert(URL,BrowserParams,p);
82+
83+ // start browser
84+ BrowserProcess:=TProcessUTF8.Create(nil);
85+ try
86+ BrowserProcess.CommandLine:=BrowserPath+' '+BrowserParams;
87+ BrowserProcess.Execute;
88+ finally
89+ BrowserProcess.Free;
90+ end;
91+ finally
92+ v.Free;
93+ end;
9694 end;
97- finally
98- v.Free;
99- end;
100-end;
10195```
10296
10397## Integrate web browser component in application
10498
10599### TurboPower Internet Pro
106100
107-Lazarus provides the package TurboPowerIPro (lazarus/components/turbopower_ipro/turbopoweripro.lpk) with the following features:
101+Lazarus provides the package TurboPowerIPro (lazarus/components/turbopower_ipro/turbopoweripro.lpk) with the following features:
108102
109-- It contains a control to put onto a form. When you install the package in the IDE, you get some new components in the palette, so you can drop them onto a form just like any LCL control.
110-- It is written completely in Pascal and therefore works on all platforms out of the box without any extra installation.
111-- You have the full control, what files/urls are opened.
112-- It does not have all the features of a full webbrowser. No multimedia stuff, javascript or flash. This must be implemented by you.
103+ * It contains a control to put onto a form. When you install the package in the IDE, you get some new components in the palette, so you can drop them onto a form just like any LCL control.
104+ * It is written completely in Pascal and therefore works on all platforms out of the box without any extra installation.
105+ * You have the full control, what files/urls are opened.
106+ * It does not have all the features of a full webbrowser. No multimedia stuff, javascript or flash. This must be implemented by you.
113107
114-There are some examples in lazarus/components/turbopower_ipro/examples demonstrating how to open a local html file with some images, hyperlinks and history buttons. See the [[IPro tab]] on the [[Component Palette]].
108+There are some examples in lazarus/components/turbopower_ipro/examples demonstrating how to open a local html file with some images, hyperlinks and history buttons. See the [[IPro tab]] on the [[Component Palette]].
115109
110+Read more [[TurboPower Internet Pro]]
111+
116112### WebView4Delphi
117113
118-[[WebView4Delphi]] allows to embed Chromium-based web browsers in your Delphi or Lazarus applications using the WebView2 runtime. It uses many of the tricks from CEF4Delphi and you will notice many similarities if you used it.
114+[[WebView4Delphi]] allows to embed Chromium-based web browsers in your Delphi or Lazarus applications using the WebView2 runtime. It uses many of the tricks from CEF4Delphi and you will notice many similarities if you used it.
119115
120-There are a few things pending like the "windowless mode".
116+There are a few things pending like the "windowless mode".
121117
122118### TWebBrowser WebKit (macOS Cocoa)
123119
124-TWebBrowser control is implemented only for the LCL Cocoa widgetset for macOS by wrapping the WebView class that's part of every Mac's WebKit framework. Note that by default macOS blocks calls to insecure HTTP sites. You can relax this restriction by setting the *NSAllowsArbitraryLoads* key in your application's [[macOS property list files|Info.plist]] file, but for testing you might stick with HTTPS sites. This control does not add any bulk to your app and does not require installation of any additional libraries. Everything it needs is already on your Mac and is accessible via the FPC CocoaAll unit. [Source](https://macpgmr.github.io/MacXPlatform/lclwebbrowser-src.zip).
120+TWebBrowser control is implemented only for the LCL Cocoa widgetset for macOS by wrapping the WebView class that's part of every Mac's WebKit framework. Note that by default macOS blocks calls to insecure HTTP sites. You can relax this restriction by setting the _NSAllowsArbitraryLoads_ key in your application's [[macOS property list files|Info.plist]] file, but for testing you might stick with HTTPS sites. This control does not add any bulk to your app and does not require installation of any additional libraries. Everything it needs is already on your Mac and is accessible via the FPC CocoaAll unit. [Source](<https://macpgmr.github.io/MacXPlatform/lclwebbrowser-src.zip>).
125121
126122### QT Webkit
127123
128-When using the Qt widgetset, you can use the Qt Webkit to embed a browser into a LCL form. Lazarus demo is available on [FPC Qt4 Binding Web Page](http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html).
124+When using the Qt widgetset, you can use the Qt Webkit to embed a browser into a LCL form. Lazarus demo is available on [FPC Qt4 Binding Web Page](<http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html>).
129125
130126### THtmlPort
131127
132-[[THtmlPort]] is a Lazarus/Free Pascal version of Dave Baldwin's HTML Components, including THtmlViewer, TFrameViewer and TFrameBrowser.
128+[[THtmlPort]] is a Lazarus/Free Pascal version of Dave Baldwin's HTML Components, including THtmlViewer, TFrameViewer and TFrameBrowser.
133129
134130### HtmlViewer
135131
136-The [HtmlViewer](https://github.com/BerndGabriel/HtmlViewer) component for Delphi and Lazarus, set consists of:
132+The [HtmlViewer](<https://github.com/BerndGabriel/HtmlViewer>) component for Delphi and Lazarus, set consists of:
137133
138-- THtmlViewer
139-- TFrameViewer
140-- TFrameBrowser
134+ * THtmlViewer
135+ * TFrameViewer
136+ * TFrameBrowser
141137
142138### fpCEF3
143139
144-[[fpCEF3]] is a Chromium Embedded Framework for Free Pascal.
140+[[fpCEF3]] is a Chromium Embedded Framework for Free Pascal.
145141
146142### CEF4Delphi
147143
148-[[CEF4Delphi]] is updated Chromium Embedded Framework, which supports Lazarus.
144+[[CEF4Delphi]] is updated Chromium Embedded Framework, which supports Lazarus.
149145
150146### GeckoPort
151147
152-[[GeckoPort]] is a Lazarus/Free Pascal version of Takanori Ito's Gecko SDK for Delphi, including the TGeckoBrowser component.
148+[[GeckoPort]] is a Lazarus/Free Pascal version of Takanori Ito's Gecko SDK for Delphi, including the TGeckoBrowser component.
153149
154150### LazActiveX
155151
156-[[LazActiveX]] allows to import MS Internet Explorer type library.
152+[[LazActiveX]] allows to import MS Internet Explorer type library.
157153
158154### LazWebkit
159155
160-[LazWebkit](http://sourceforge.net/p/lazwebkit/wiki/Home/) is a project focused to provide browser and composer web content features for Lazarus IDE based projects. Currently it's implemented only for GTK2 widgetset.
156+[LazWebkit](<http://sourceforge.net/p/lazwebkit/wiki/Home/>) is a project focused to provide browser and composer web content features for Lazarus IDE based projects. Currently it's implemented only for GTK2 widgetset.
161157
162158## See also
163159
164-- [[Executing External Programs]]
165-- [[fphttpclient]] Part of fcl-web that can be used stand-alone to retrieve HTTP-Content
166-- [[fpbrowser]] web browser written in Lazarus
167-- [[fpwebview]] cross-platform library for Linux, macOS and Windows for building desktop applications using Pascal and web technology
168-- [[Windows Programming Tips|Using Windows native WinInet for web retrieval]]
169-- [[macOS NSURLSession]] - the replacement for [[macOS NSURLConnection|NSURLConnection]] for web retrieval.
160+ * [[Executing External Programs]]
161+ * [[fphttpclient]] Part of fcl-web that can be used stand-alone to retrieve HTTP-Content
162+ * [[fpbrowser]] web browser written in Lazarus
163+ * [[fpwebview]] cross-platform library for Linux, macOS and Windows for building desktop applications using Pascal and web technology
164+ * [[Windows Programming Tips|Using Windows native WinInet for web retrieval]]
165+ * [[macOS NSURLSession]] \- the replacement for [[macOS NSURLConnection|NSURLConnection]] for web retrieval.
170166
171167---
172-*From the Free Pascal wiki, page "Webbrowser", as it stood on 2022-02-18 after a change by PierceNg, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
168+*From the Free Pascal wiki, page "Webbrowser", as the Internet Archive kept it on 2026-01-31, last changed on 2025-04-29. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history