Platforms to show: All Mac Windows Linux Cross-Platform

Back to DesktopWebView2ControlMBS control.

DesktopWebView2ControlMBS.AddScriptToExecuteOnDocumentCreatedCompleted(JavaScript as String, ErrorCode as Integer, ID as String, Tag as Variant)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event to report that AddScriptToExecuteOnDocumentCreated is done and provide the ID.

DesktopWebView2ControlMBS.CapturePreviewCompleted(ImageFormat as Integer, ErrorCode as Integer, PictureData as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event called when CapturePreview call is done.

We pass you the image data as a string, so you can e.g. write it to a PNG or JPEG file.
Otherwise ErrorCode tells you the reason for the error.

DesktopWebView2ControlMBS.Closing

Type Topic Version
event WebView2 21.5

The control is about to close.
In older Xojo versions, this event is named Close.

DesktopWebView2ControlMBS.Configure

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event called while initializing, where you can apply properties just before plugin reads them.

Can be used to set UserDataFolder property.

DesktopWebView2ControlMBS.ConstructContextualMenu(base as DesktopMenuItem, x as Integer, y as Integer) As Boolean

Type Topic Version
event WebView2 22.1
This event is called when it is appropriate to display a contextual menu for the control.

DesktopWebView2ControlMBS.ContainsFullScreenElementChanged

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
ContainsFullScreenElementChanged fires when the ContainsFullScreenElement property changes.

This means that an HTML element inside the WebView is entering fullscreen to the size of the WebView or leaving fullscreen. This event is useful when, for example, a video element requests to go fullscreen. The listener of ContainsFullScreenElementChanged can then resize the WebView in response.

DesktopWebView2ControlMBS.ContentLoading(isErrorPage as Boolean, NavigationID as UInt64)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The content loading event.d

ContentLoading fires before any content is loaded, including scripts added with AddScriptToExecuteOnDocumentCreated. ContentLoading will not fire if a same page navigation occurs (such as through fragment navigations or history.pushState navigations). This follows the NavigationStarting and SourceChanged events and precedes the HistoryChanged and NavigationCompleted events.

DesktopWebView2ControlMBS.ContextualMenuItemSelected(selectedItem As DesktopMenuItem) As Boolean

Type Topic Version
event WebView2 22.1
Called when a menuitem is choosen.

This allows the control to react on its relevant menu items. Please return true if you handled it or false to give others a chance.

DesktopWebView2ControlMBS.DocumentTitleChanged

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event to report a document title change.

DocumentTitleChanged fires when the DocumentTitle property of the WebView changes and may fire before or after the NavigationCompleted event.

DesktopWebView2ControlMBS.ExecuteScriptCompleted(JavaScript as String, ErrorCode as Integer, resultObjectAsJson as String, Tag as Variant)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event to report ExecuteScript method is done.

DesktopWebView2ControlMBS.FocusLost

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No

LostFocus fires when WebView lost focus.
In older Xojo versions, this event is named LostFocus.

In the case where MoveFocusRequested event is fired, the focus is still on WebView when MoveFocusRequested event fires. LostFocus only fires afterwards when app's code or default action of MoveFocusRequested event set focus away from WebView.

DesktopWebView2ControlMBS.FocusReceived

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No

GotFocus fires when WebView got focus.
In older Xojo versions, this event is named GotFocus.

DesktopWebView2ControlMBS.FrameNavigationCompleted(isSuccess as Boolean, ErrorStatus as Integer, NavigationID as UInt64)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
FrameNavigationCompleted fires when a child frame has completely loaded (body.onload has fired) or loading stopped with error.

DesktopWebView2ControlMBS.FrameNavigationStarting(URL as String, IsUserInitiated as Boolean, IsRedirected as Boolean, NavigationID as UInt64) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
FrameNavigationStarting fires when a child frame in the WebView requests permission to navigate to a different URI. This will fire for redirects as well.

Corresponding navigations can be blocked until the event handler returns.
Return true to block the request.

DesktopWebView2ControlMBS.HistoryChanged

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event to report history change.

HistoryChanged listens to the change of navigation history for the top level document. Use HistoryChanged to check if CanGoBack/CanGoForward value has changed. HistoryChanged also fires for using GoBack/GoForward. HistoryChanged fires after SourceChanged and ContentLoading.

DesktopWebView2ControlMBS.MenuBarSelected

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 22.1 ❌ No ✅ Yes ❌ No ❌ No

The event where you can enable menu items.
In older Xojo versions, this event is named EnableMenuItems.

DesktopWebView2ControlMBS.NavigationCompleted(isSuccess as Boolean, ErrorStatus as Integer, NavigationID as UInt64)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event to report a navigation action completed.

NavigationCompleted fires when the WebView has completely loaded (body.onload has fired) or loading stopped with error.

Please don't process directly here, but maybe call a method with timer.CallLater to do processing like using HTMLText or PlainText functions.

Like the DocumentCompleted event in Xojo.

DesktopWebView2ControlMBS.NavigationStarting(URL as String, IsUserInitiated as Boolean, IsRedirected as Boolean, NavigationID as UInt64) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event to report a navigation action.

NavigationStarting fires when the WebView main frame is requesting permission to navigate to a different URI. This will fire for redirects as well.
Corresponding navigations can be blocked until the event handler returns.

Return true to cancel it like Xojo's CancelLoad event.

This event is great to check the URL. If you like to block it, you may just return true. If the user initiated the request, you may instead want to load a warning page. Also check the URL and decide whether to turn scripting on or off.

DesktopWebView2ControlMBS.NewWindowRequested(URL as String, IsUserInitiated as Boolean, WindowFeatures as WebView2WindowFeaturesMBS, byref NewWindow as Variant) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event called when a new window needs to be opened.

Return true to indicate you handled the event.
If you create a new window with a DesktopWebView2ControlMBS (or DesktopDesktopWebView2ControlMBS), you can put it in NewWindow property.

IsUserInitiated:
True when the new window request was initiated through a user gesture.

Examples of user initiated requests are:
Selecting an anchor tag with target
Programmatic window open from a script that directly run as a result of user interaction such as via onclick handlers.
Non-user initiated requests are programmatic window opens from a script that are not directly triggered by user interaction, such as those that run while loading a new page or via timers. The Microsoft Edge popup blocker is disabled for WebView so the app is able to use this flag to block non-user initiated popups.

URL: The target uri of the new window requested.

NewWindow: Set the new control to use.

If the NewWindow is set, the top-level window returns as the opened WindowProxy. The NewWindow property should be set to a control that has not been navigated previously. Don't use methods that cause navigation or interact with the DOM on this web view. Setting event handlers, changing Settings properties, or other methods are fine to call. Changes to settings should be made before NewWindow is called to ensure that those settings take effect for the newly setup WebView. Once the NewWindow is set the underlying web contents of this CoreWebView2 will be replaced and navigated as appropriate for the new window. After setting new window it cannot be changed and error will be return otherwise.

DesktopWebView2ControlMBS.Opened

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event called when browser initialization is done.

Typical event flow is like this:

  • Configure
  • Open
  • Window.Open
  • Opened

Opened is called a few milliseconds later.

If you load an URL, the events happen like this:

  • NavigationStarting
  • SourceChanged
  • ContentLoading
  • HistoryChanged
  • DocumentTitleChanged
  • NavigationCompleted

DesktopWebView2ControlMBS.Opening

Type Topic Version
event WebView2 21.5

The control is about to was created and you can initialize it.
In older Xojo versions, this event is named Open.

DesktopWebView2ControlMBS.PermissionRequested(URL as String, PermissionKind as Integer, IsUserInitiated as Boolean, byref State as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event to query permissions from user.

PermissionRequested fires when content in a WebView requests permission to access some privileged resources.
If a deferral is not taken on the event args, the subsequent scripts can be blocked until the event handler returns. If a deferral is taken, then the scripts are blocked until the deferral is completed.

URL: The origin of the web content that requests the permission.
PermissionKind: The type of the permission that is requested.
IsUserInitiated: True when the permission request was initiated through a user gesture.
State: The status of a permission request, i.e.

Please assign State the answer you like to provide.

DesktopWebView2ControlMBS.PrintCompleted(Path as String, errorCode as Integer, isSuccessful as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 23.1 ❌ No ✅ Yes ❌ No ❌ No
Receives the result of the PrintToPdf method.

If the print to PDF operation succeeds, isSuccessful is true. Otherwise, if the operation failed, isSuccessful is set to false. An invalid path returns E_INVALIDARG in errorCode.

DesktopWebView2ControlMBS.ProcessFailed(processFailedKind as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
ProcessFailed fires when a WebView process is terminated unexpectedly or becomes unresponsive.

DesktopWebView2ControlMBS.SourceChanged(isNewDocument as Boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event to report a change in the URL.

SourceChanged fires when the Source property changes. SourceChanged fires for navigating to a different site or fragment navigations. It will not fire for other types of navigations such as page reloads or history.pushState with the same URL as the current page. SourceChanged fires before ContentLoading for navigation to a new document.

DesktopWebView2ControlMBS.WebMessageReceived(Source as String, webMessageAsJson as String, webMessageAsString as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event called for a web message.

WebMessageReceived fires when the IsWebMessageEnabled setting is set and the top level document of the WebView calls window.chrome.webview.postMessage. The postMessage function is void postMessage(object) where object is any object supported by JSON conversion.

webMessageAsString is empty if we can't serialize it to text.

DesktopWebView2ControlMBS.WindowCloseRequested

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
The event where JavaScript asks to close window.

WindowCloseRequested fires when content inside the WebView requested to close the window, such as after window.close is called. The app should close the WebView and related app window if that makes sense to the app.

DesktopWebView2ControlMBS.ZoomFactorChanged

Type Topic Plugin Version macOS Windows Linux iOS Targets
event WebView2 MBS WinFrameworks Plugin 21.5 ❌ No ✅ Yes ❌ No ❌ No
ZoomFactorChanged fires when the ZoomFactor property of the WebView changes.

The event could fire because the caller modified the ZoomFactor property, or due to the user manually modifying the zoom. When it is modified by the caller via the ZoomFactor property, the internal zoom factor is updated immediately and there will be no ZoomFactorChanged event. WebView associates the last used zoom factor for each site. Therefore, it is possible for the zoom factor to change when navigating to a different page. When the zoom factor changes due to this, the ZoomFactorChanged event fires right after the ContentLoading event.

The items on this page are in the following plugins: MBS WinFrameworks Plugin.


The biggest plugin in space...