Browser Features

October 22, 2023 ยท View on GitHub

Overview

This article mainly introduces how to use WinFormium's form Formium class and its content related to browser functions. The form-related content in the Formium class will be introduced in ["Form Function"](./Form Function.md).

Load web page

You can use the Url attribute to specify the address of the web page that needs to be loaded. Before the browser is initialized, you can specify the Url attribute in the constructor, then the specified web page will be automatically loaded after the browser is loaded. If the browser is loaded, modifying the Url attribute will load the new web page immediately.

In addition, Formium provides the Reload method to reload the current web page. You can call this method to reload the current web page when needed. This method has an optional ignoreCache parameter, which if set to true will ignore the cache when reloading the web page.

You can use the GoBack and GoForward methods to implement the browser's forward and backward functionality. Before calling these two methods, you can first determine whether the value of the CanGoBack and CanGoForward properties is true. If it is true, you can call the GoBack and GoForward methods.

Debugging tools

You can display the browser's debugging tools using the ShowDevTools method of the Formium class. Use the CloseDevTools method to hide debugging tools. Use the HasDevTools property to determine whether debugging tools are displayed.

Execute JavaScript code

You can use the ExecuteJavaScript method to execute JavaScript code. You can also use the EvaluateJavaScript method to execute JavaScript code and return the execution results.

For more information about executing JavaScript in WinFormium, see the JavaScript chapter.

Web page title

You can use the UsePageTitle property to specify whether to use the page title to set the form title. If set to true, the page title will be used to set the form title. If set to false, the default form title will be used to set the form title.

API Reference

Attributes

Common Properties

Property nameDescriptionTypeDefault value
CanGoBackGets a value indicating whether the browser can navigate backwards.boolfalse
CanGoForwardGets a value indicating whether the browser can navigate forward.boolfalse
ChromiumEnvironmentGet the Chromium environment of the current browser.ChromiumEnvironment
HasDevToolsGets a value indicating whether the browser's debugging tools have been displayed.boolfalse
IsLoadingGets a value that indicates whether the browser is loading the web page.boolfalse
UrlGet or set the address of the web page currently loaded by the browser.string"formium:blank"
UsePageTitleGets or sets a value indicating whether to use the page title to set the form title.booltrue

BrowserClient interface properties

Attribute nameDescriptionType
AudioHandlerGets or sets the browser's audio handler.WinFormium.AudioHandler
ContextMenuHandlerGets or sets the browser's context menu handler.WinFormium.ContextMenuHandler
DialogHandlerGets or sets the browser's dialog handler.WinFormium.DialogHandler
DisplayHandlerGets or sets the browser's display handler.WinFormium.DisplayHandler
DownloadHandlerGets or sets the browser's download handler.WinFormium.DownloadHandler
DragHandlerGets or sets the browser's drag and drop handler.WinFormium.DragHandler
FindHandlerGets or sets the browser's find handler.WinFormium.FindHandler
FocusHandlerGets or sets the browser's focus handler.WinFormium.FocusHandler
FrameHandlerGets or sets the browser's frame handler.WinFormium.FrameHandler
JsDialogHandlerGets or sets the browser's JavaScript dialog handler.WinFormium.JsDialogHandler
KeyboardHandlerGets or sets the browser's keyboard handler.WinFormium.KeyboardHandler
LifeSpanHandlerGets or sets the browser's life cycle handler.WinFormium.LifeSpanHandler
LoadHandlerGets or sets the browser's load handler.WinFormium.LoadHandler
PermissionHandlerGets or sets the browser's permission handler.WinFormium.PermissionHandler
RenderHandlerGets or sets the browser's rendering handler.WinFormium.RenderHandler
RequestHandlerGets or sets the browser's request handler.WinFormium.RequestHandler

Methods

Method nameDescriptionReturn value
BeginRegisterJavaScriptObject(CefFrame)Start registering JavaScript objects.JavaScriptObjectRegisterHandle
RegisterJavaScriptObject(JavaScriptObjectRegisterHandle,string, JavaScriptObject)Register a JavaScript object.bool
RegisterJavaScriptObject(JavaScriptObjectRegisterHandle,string, JavaScriptObjectWrapper)Register a JavaScript object.bool
EndRegisterJavaScriptObject(JavaScriptObjectRegisterHandle)End registration of JavaScript objects.void
EvaluateJavaScript(string,string,int)Execute JavaScript code and return the execution result.Task
EvaluateJavaScript(CefFrame,string,string,int)Execute JavaScript code and return the execution result.Task
ExecuteJavaScript(string,string,int)Execute JavaScript code.void
ExecuteJavaScript(CefFrame,string,string,int)Execute JavaScript code.void
GoBack()Navigate to the previous web page.void
GoForward()Navigate to the next web page.void
ShowDevTools()Shows the browser's debugging tools.void
CloseDevTools()Hide the browser's debugging tools.void
Reload(bool)Reload the current web page.void
PostBrowserJavaScriptMessage(string,JavaScriptValue)Send a JavaScript message to the current browser.void

Events

Event nameDescriptionParameters
BeforeBrowseOccurs before the browser navigates to a new web page.BeforeBrowseEventArgs
BeforeDownloadOccurs before the browser starts downloading the file.BeforeDownloadEventArgs
BeforeKeyEventOccurs before the browser receives a keyboard event.BeforeKeyEventEventArgs
BrowserCreatedOccurs after the browser is created.BrowserCreatedEventArgs
CanDownloadOccurs before the browser starts downloading the file.CanDownloadEventArgs
ConsoleMessageOccurs when a message is output to the browser console.ConsoleMessageEventArgs
CursorChangeOccurs when the browser's cursor changes.CursorChangeEventArgs
DocumentAvailableOccurs after the browser loads the web document.DocumentAvailableEventArgs
DownloadUpdatedOccurs when the browser downloads a file.DownloadUpdatedEventArgs
FaviconUrlChangeOccurs when the browser's web page icon changes.FaviconUrlChangeEventArgs
FramePageAddressChangeOccurs when the browser's web page address changes.FramePageAddressChangeEventArgs
FramePageLoadEndOccurs after the browser's web page has finished loading.FramePageLoadEndEventArgs
FramePageLoadErrorOccurs when the browser's web page fails to load.FramePageLoadErrorEventArgs
FramePageLoadStartOccurs after the browser's web page starts loading.FramePageLoadStartEventArgs
FullscreenModeChangeOccurs when the browser's full screen mode changes.FullscreenModeChangeEventArgs
GetAuthCredentialsOccurs when the browser requires the user to enter credentials.GetAuthCredentialsEventArgs
KeyEventOccurs when the browser receives a keyboard event.KeyEventArgs
MediaAccessChangeOccurs when the browser's media access permissions change.MediaAccessChangeEventArgs
OpenUrlFromTabOccurs when the browser needs to open a new web page.OpenUrlFromTabEventArgs
PageAddressChangeOccurs when the browser's web page address changes.PageAddressChangeEventArgs
PageLoadEndOccurs after the browser's page has finished loading.PageLoadEndEventArgs
PageLoadErrorOccurs when the browser fails to load a web page.PageLoadErrorEventArgs
PageLoadStartOccurs after the browser page has started loading.PageLoadStartEventArgs
PageLoadingProgressChangeOccurs when the browser's page loading progress changes.PageLoadingProgressChangeEventArgs
PageLoadingStateChangeOccurs when the browser's page loading state changes.PageLoadingStateChangeEventArgs
PageTitleChangeOccurs when the browser's page title changes.PageTitleChangeEventArgs
RenderProcessCrashedOccurs when the browser's rendering process crashes.RenderProcessCrashedEventArgs
SetFocusOccurs when the browser gains focus.SetFocusEventArgs
StatusMessageChangeOccurs when the browser's status message changes.StatusMessageChangeEventArgs
TakeFocusOccurs when the browser loses focus.TakeFocusEventArgs
TooltipOccurs when the browser's tooltip changes.TooltipEventArgs

See also