Table of Contents

TTMSFNCWebBrowser Class

Cross-platform embeddable web browser control that supports navigation, JavaScript execution, download management, cookie access, printing, DevTools, and virtual host mapping.

API unit family: TMSFNCWebBrowser Inherits from: TTMSFNCCustomWebBrowser

Syntax

TTMSFNCWebBrowser = class(TTMSFNCCustomWebBrowser)

Properties

Name Description
AutoClearCache When True, the cache is cleared automatically each time the browser control is destroyed. (inherited from TTMSFNCCustomWebBrowser)
CacheFolder Local folder used to store the browser cache. Leave empty to use the default platform cache location. (inherited from TTMSFNCCustomWebBrowser)
CacheFolderName Sub-folder name within CacheFolder used to isolate this browser instance's cache. (inherited from TTMSFNCCustomWebBrowser)
DesigntimeEnabled When True (default), the browser renders a placeholder at design time. Set to False to suppress the design-time view. (inherited from TTMSFNCCustomWebBrowser)
Downloads Collection of active and completed downloads tracked by the browser. See TTMSFNCWebBrowserDownloads. (inherited from TTMSFNCCustomWebBrowser)
EnableAcceleratorKeys When True, browser keyboard accelerator keys (such as Ctrl+F) are active. (inherited from TTMSFNCCustomWebBrowser)
EnableContextMenu When True, the browser shows its native right-click context menu. Set to False to suppress or replace it. (inherited from TTMSFNCCustomWebBrowser)
EnableShowDebugConsole When True, the developer tools console can be opened via keyboard shortcut or ShowDebugConsole. (inherited from TTMSFNCCustomWebBrowser)
Settings Browser behaviour settings such as context menus, accelerator keys, language, and additional command-line arguments. (inherited from TTMSFNCCustomWebBrowser)
URL URL to navigate to. Setting this property at runtime navigates immediately when the browser is ready. (inherited from TTMSFNCCustomWebBrowser)
UserAgent User-agent string sent with HTTP requests. Leave empty to use the browser's default user-agent. (inherited from TTMSFNCCustomWebBrowser)
Version Version string of the browser control. (inherited from TTMSFNCCustomWebBrowser)

Methods

Name Description
AddBridge Registers a Delphi object as a JavaScript-accessible bridge under the given name.
AddCookie Adds or updates a cookie in the browser's cookie store.
CallDevToolsProtocolMethod Invokes a DevTools Protocol method with a JSON parameters object. Results are delivered via OnDevToolsMethodCompleted.
CanGoBack Returns True when the browser has a previous page in its history.
CanGoForward Returns True when the browser has a next page in its history.
CaptureScreenShot Captures a screenshot of the current browser content.
ClearCache Clears the browser cache immediately.
ClearVirtualHostNameToFolderMapping Removes a virtual host-name-to-folder mapping previously set via SetVirtualHostNameToFolderMapping.
DeInitialize Shuts down the underlying browser engine and releases its resources.
DeleteAllCookies Deletes all cookies from the browser's cookie store.
DeleteCookie Deletes a specific cookie identified by name, domain, and path.
ExecuteJavaScript Executes a JavaScript expression in the current page context.
ExecuteJavaScriptSync Executes a JavaScript expression synchronously and returns its string result.
GetBridgeCommunicationLayer Returns the JavaScript bootstrap code that must be injected into a page to enable communication with a named bridge.
GetCookies Asynchronously retrieves cookies for the specified URI. Results are delivered via OnGetCookies.
GetDownloadInterruptReasonText Returns a human-readable description of a download interrupt reason.
GetDownloadStateText Returns a human-readable description of a download state.
GetWebBrowserInstance Returns the Windows-specific browser instance interface (e.g. ICoreWebView2Controller). Windows only.
GoBack Navigates the browser to the previous page in its history, if available. Check CanGoBack before calling.
GoForward Navigates the browser to the next page in its history, if available. Check CanGoForward before calling.
InitialPrintSettings Returns a TTMSFNCWebBrowserPrintSettings record populated with sensible default values.
Initialize Initialises the underlying browser engine. Called automatically when the control is first shown; call manually only when re-initialisation is needed after DeInitialize.
IsFMXBrowser Returns True when the browser is hosted inside an FMX application.
LoadFile Loads a local HTML file into the browser.
LoadHTML Loads an HTML string directly into the browser without navigating to a URL.
NativeBrowser Returns a pointer to the native browser instance. The type depends on the platform (e.g. ICoreWebView2 on Windows).
NativeDialog Returns a pointer to the native Android dialog associated with the browser. Android only.
NativeEnvironment Returns a pointer to the native browser environment object. The type depends on the platform (e.g. ICoreWebView2Environment on Windows).
Navigate Navigates to the URL set in the URL property.
NavigateWithData Navigates to a URI using a custom HTTP method and a string body.
OpenTaskManager Opens the browser's built-in task manager window showing per-process resource usage.
Print Prints the current page using the supplied settings.
PrintToPDF Saves the current page as a PDF file using the supplied settings.
PrintToPDFStream Renders the current page to a PDF stream using the supplied settings. The result is delivered via OnGetPrintPDFStream.
Reload Reloads the current page.
RemoveBridge Unregisters a previously added JavaScript bridge.
SetVirtualHostNameToFolderMapping Maps a virtual host name to a local folder so that pages loaded from AHostName can access local files via that URI.
ShowDebugConsole Opens the browser's built-in developer tools console window. Requires Settings.EnableShowDebugConsole to be True.
ShowPrintUI Displays the browser's built-in print dialog to let the user choose a printer.
StartDocumentReadyStateThread Starts the background thread that polls the browser document ready state and fires OnDocumentComplete when the page is fully loaded. Called internally; override only to customise the ready-state detection behaviour.
StopLoading Stops any page load in progress.
SubscribeDevtools Subscribes to a DevTools Protocol event by name. Results are delivered via OnDevToolsSubscribedEvent.
UpdateControlAfterResize Updates the native browser layout after the control has been resized. (inherited from TTMSFNCCustomWebBrowser)

Events

Name Description
OnBeforeFrameNavigate Fired before a sub-frame begins loading. (inherited from TTMSFNCCustomWebBrowser)
OnBeforeNavigate Fired before the main frame begins loading a URL. Set Params.Cancel to block the navigation. (inherited from TTMSFNCCustomWebBrowser)
OnCaptureScreenShot Fired when a screenshot requested by CaptureScreenShot is ready. (inherited from TTMSFNCCustomWebBrowser)
OnCloseForm Fired when the form hosting the browser is closed from within a web page (for example via window.close()). (inherited from TTMSFNCCustomWebBrowser)
OnContainsFullScreenElementChanged Fired when the browser's full-screen element state changes. (inherited from TTMSFNCCustomWebBrowser)
OnCustomContextMenuItemSelected Fired when the user clicks a custom context menu item added via OnGetContextMenu. (inherited from TTMSFNCCustomWebBrowser)
OnDOMContentLoaded Fired when the browser's DOM content has loaded (equivalent to the JavaScript DOMContentLoaded event). (inherited from TTMSFNCCustomWebBrowser)
OnDevToolsMethodCompleted Fired when a DevTools Protocol method call invoked via CallDevToolsProtocolMethod completes. (inherited from TTMSFNCCustomWebBrowser)
OnDevToolsSubscribedEvent Fired when a DevTools Protocol event subscribed via SubscribeDevtools is received. (inherited from TTMSFNCCustomWebBrowser)
OnDocumentComplete Fired when the page document has finished loading. (inherited from TTMSFNCCustomWebBrowser)
OnDocumentTitleChanged Fired when the document title of the current page changes. (inherited from TTMSFNCCustomWebBrowser)
OnDownloadBytesReceivedChanged Fired each time the number of bytes received by a running download changes. (inherited from TTMSFNCCustomWebBrowser)
OnDownloadStarted Fired when a new download starts. (inherited from TTMSFNCCustomWebBrowser)
OnDownloadStateChanged Fired each time the state of a running download changes. (inherited from TTMSFNCCustomWebBrowser)
OnError Fired when the browser encounters a runtime or initialisation error. (inherited from TTMSFNCCustomWebBrowser)
OnFrameNavigateComplete Fired after a sub-frame finishes loading. (inherited from TTMSFNCCustomWebBrowser)
OnGetConsoleMessage Fired for each console message logged by the page when the Log DevTools domain is active. (inherited from TTMSFNCCustomWebBrowser)
OnGetContextMenu Fired when the browser is about to show a context menu, allowing the application to inspect or modify the item list. (inherited from TTMSFNCCustomWebBrowser)
OnGetCookies Fired when cookies are retrieved in response to a GetCookies call. (inherited from TTMSFNCCustomWebBrowser)
OnGetPopupMenuForContextMenu Fired when a context menu is requested and Settings.UsePopupMenuAsContextMenu is True. (inherited from TTMSFNCCustomWebBrowser)
OnGetPrintPDFStream Fired when a PDF memory stream is ready after a PrintToPDFStream call. (inherited from TTMSFNCCustomWebBrowser)
OnHardwareButtonClicked Fired when the user presses a hardware back/forward button on mobile. (inherited from TTMSFNCCustomWebBrowser)
OnHistoryChanged Fired when the browser's navigation history changes. (inherited from TTMSFNCCustomWebBrowser)
OnInitialized Fired once when the browser engine has finished initialising and is ready to navigate. (inherited from TTMSFNCCustomWebBrowser)
OnNavigateComplete Fired after the main frame finishes loading a URL. (inherited from TTMSFNCCustomWebBrowser)
OnNewWindowRequested Fired when the page requests that a new browser window be opened. (inherited from TTMSFNCCustomWebBrowser)
OnPermissionRequested Fired when the page requests a device or browser permission. (inherited from TTMSFNCCustomWebBrowser)
OnPrinted Fired when a Print operation completes. (inherited from TTMSFNCCustomWebBrowser)
OnPrintedToPDF Fired when a PrintToPDF or PrintToPDFStream operation completes. (inherited from TTMSFNCCustomWebBrowser)
OnProcessFailed Fired when a browser subprocess exits unexpectedly. (inherited from TTMSFNCCustomWebBrowser)
OnScriptDialogOpening Fired when the page triggers a JavaScript dialog. (inherited from TTMSFNCCustomWebBrowser)
OnSourceChanged Fired when the URL of the top-level document changes without a full page navigation. (inherited from TTMSFNCCustomWebBrowser)
OnWebMessageReceived Fired when JavaScript calls window.chrome.webview.postMessage(). (inherited from TTMSFNCCustomWebBrowser)
OnWebResourceRequested Fired for each network request that matches the active resource filter. (inherited from TTMSFNCCustomWebBrowser)
OnWindowCloseRequested Fired when the page requests that the browser window be closed. (inherited from TTMSFNCCustomWebBrowser)

Used by