Platforms to show: All Mac Windows Linux Cross-Platform
WebView2ControlMBS control
See also desktop control: DesktopWebView2ControlMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
control | WebView2 | MBS WinFrameworks Plugin | 20.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | Desktop only |
Notes:
Read about WebView2 control here: |
There you also fine the installers needed to install it, unless you have the 2021 version of Windows, which may include it preinstalled.
If you use this control on macOS and Linux, it will do nothing.
On Windows if the control fails to initialize, the Opened event will not fire.
But if it fires, it will be some time after the open event fired as initialization is asynchronous.
If you call LoadURL, LoadHTML or set URL property too early, we cache that and perform the action later when the web viewer is initialized properly.
If you add an event, we register it with the C++ control. So if you don't specify an event, you may get the default behavior.
All functions may raise WebView2ExceptionMBS in case of errors.
- 33 events
- event AddScriptToExecuteOnDocumentCreatedCompleted(JavaScript as String, ErrorCode as Integer, ID as String, Tag as Variant)
- event CapturePreviewCompleted(ImageFormat as Integer, ErrorCode as Integer, PictureData as String)
- event Close
- event Closing
- event Configure
- event ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) as Boolean
- event ContainsFullScreenElementChanged
- event ContentLoading(isErrorPage as Boolean, NavigationID as UInt64)
- event ContextualMenuAction(hitItem as MenuItem) as Boolean
- event DocumentTitleChanged
- event EnableMenuItems
- event ExecuteScriptCompleted(JavaScript as String, ErrorCode as Integer, resultObjectAsJson as String, Tag as Variant)
- event FocusLost
- event FocusReceived
- event FrameNavigationCompleted(isSuccess as Boolean, ErrorStatus as Integer, NavigationID as UInt64)
- event FrameNavigationStarting(URL as String, IsUserInitiated as Boolean, IsRedirected as Boolean, NavigationID as UInt64) as Boolean
- event GotFocus
- event HistoryChanged
- event LostFocus
- event MenuBarSelected
- event NavigationCompleted(isSuccess as Boolean, ErrorStatus as Integer, NavigationID as UInt64)
- event NavigationStarting(URL as String, IsUserInitiated as Boolean, IsRedirected as Boolean, NavigationID as UInt64) as Boolean
- event NewWindowRequested(URL as String, IsUserInitiated as Boolean, WindowFeatures as WebView2WindowFeaturesMBS, byref NewWindow as Variant) as Boolean
- event Open
- event Opened
- event Opening
- event PermissionRequested(URL as String, PermissionKind as Integer, IsUserInitiated as Boolean, byref State as Integer)
- event PrintCompleted(Path as String, errorCode as Integer, isSuccessful as boolean) New in 23.1
- event ProcessFailed(processFailedKind as Integer)
- event SourceChanged(isNewDocument as Boolean)
- event WebMessageReceived(Source as String, webMessageAsJson as String, webMessageAsString as String)
- event WindowCloseRequested
- event ZoomFactorChanged
- 28 properties
- property AdditionalBrowserArguments as String
- property AllowSingleSignOnUsingOSPrimaryAccount as Boolean
- property areBrowserAcceleratorKeysEnabled as Boolean
- property AreDefaultContextMenusEnabled as Boolean
- property AreDefaultScriptDialogsEnabled as Boolean
- property AreDevToolsEnabled as Boolean
- property AreHostObjectsAllowed as Boolean
- property BrowserExecutableFolder as String
- property BrowserVersionString as String
- property ContainsFullScreenElement as Boolean
- property CookieManager as WebView2CookieManagerMBS New in 23.1
- property DefaultBackgroundColor as Color
- property DocumentTitle as String
- property IsBuiltInErrorPageEnabled as Boolean
- property IsGeneralAutofillEnabled as Boolean
- property IsPasswordAutosaveEnabled as Boolean
- property IsPinchZoomEnabled as Boolean
- property IsScriptEnabled as Boolean
- property IsStatusBarEnabled as Boolean
- property IsWebMessageEnabled as Boolean
- property IsZoomControlEnabled as Boolean
- property Language as String
- property ProcessID as Integer
- property TargetCompatibleBrowserVersion as String
- property URL as String
- property UserAgent as String
- property UserDataFolder as String
- property ZoomFactor as Double
- 27 methods
- method AddScriptToExecuteOnDocumentCreated(JavaScript as String, tag as variant = nil)
- method AddWebResourceRequestedFilter(URL as String, resourceType as Integer)
- method CanGoBack as Boolean
- method CanGoForward as Boolean
- method CapturePreview(ImageFormat as Integer = 0)
- method ClearSelection
- method Copy
- method Cut
- method ExecuteScript(JavaScript as String, tag as variant = nil)
- method ExecuteScriptSync(JavaScript as String, byref ErrorCode as Integer) as String
- method GoBack
- method GoForward
- method HTMLText as String
- method LoadHTML(HTML as String)
- method LoadURL(URL as String)
- method OpenDevToolsWindow
- method Paste
- method PlainText as String
- method PostWebMessageAsJson(webMessageAsJson as String)
- method PostWebMessageAsString(webMessageAsString as String)
- method Print
- method PrintToPdf(Path as String) New in 23.1
- method Reload
- method RemoveScriptToExecuteOnDocumentCreated(ID as String
- method RemoveWebResourceRequestedFilter(URL as String, resourceType as Integer)
- method SelectAll
- method Stop
- shared method AvailableCoreWebView2BrowserVersionString as string
- 49 constants
Image Formats
Constant | Value | Description |
---|---|---|
kCapturePreviewImageFormatJPEG | 1 |
JPEG format. |
kCapturePreviewImageFormatPNG | 0 |
PNG format. |
Permission Kind
Constant | Value | Description |
---|---|---|
kPermissionKindCamera | 2 |
Permission to capture video. |
kPermissionKindClipboardRead | 6 |
Permission to read system clipboard without a user gesture. |
kPermissionKindGeoLocation | 3 |
Permission to access geolocation. |
kPermissionKindMicrophone | 1 |
Permission to capture audio. |
kPermissionKindNotifications | 4 |
Permission to send web notifications. |
kPermissionKindOtherSensors | 5 |
Permission to access generic sensor. |
kPermissionKindUnknownPermission | 0 |
Unknown permission. |
Permission States
Constant | Value | Description |
---|---|---|
kPermissionStateAllow | 1 |
Grant the permission request. |
kPermissionStateDefault | 0 |
Use default browser behavior, which normally prompt users for decision. |
kPermissionStateDeny | 2 |
Deny the permission request. |
Process Failure Kinds
Constant | Value | Description |
---|---|---|
kProcessFailedKindBrowserProcessExited | 0 |
Indicates the browser process terminated unexpectedly. |
kProcessFailedKindRenderProcessExited | 1 |
Indicates the render process terminated unexpectedly. |
kProcessFailedKindRenderProcessUnresponsive | 2 |
Indicates the render process becomes unresponsive. |
Error Status Values
Constant | Value | Description |
---|---|---|
kWebErrorStatusCannotConnect | 12 |
Cannot connect to destination. |
kWebErrorStatusCertificateCommonNameIsIncorrect | 1 |
The SSL certificate common name does not match the web address. |
kWebErrorStatusCertificateExpired | 2 |
The SSL certificate has expired. |
kWebErrorStatusCertificateIsInvalid | 5 |
The SSL certificate is invalid – this could mean the certificate did not match the public key pins for the host name, the certificate is signed by an untrusted authority or using a weak sign algorithm, the certificate claimed DNS names violate name constraints, the certificate contains a weak key, the certificate's validity period is too long, lack of revocation information or revocation mechanism, non-unique host name, lack of certificate transparency information, or the certificate is chained to a legacy Symantec root. |
kWebErrorStatusCertificateRevoked | 4 |
The SSL certificate has been revoked. |
kWebErrorStatusClientCertificateContainsErrors | 3 |
The SSL client certificate contains errors. |
kWebErrorStatusConnectionAborted | 9 |
The connection was aborted. |
kWebErrorStatusConnectionReset | 10 |
The connection was reset. |
kWebErrorStatusDisconnected | 11 |
The Internet connection has been lost. |
kWebErrorStatusErrorHttpInvalidServerResponse | 8 |
The server returned an invalid or unrecognized response. |
kWebErrorStatusHostNameNotResolved | 13 |
Could not resolve provided host name. |
kWebErrorStatusOperationCanceled | 14 |
The operation was canceled. |
kWebErrorStatusRedirectFailed | 15 |
The request redirect failed. |
kWebErrorStatusServerUnreachable | 6 |
The host is unreachable. |
kWebErrorStatusTimeout | 7 |
The connection has timed out. |
kWebErrorStatusUnexpectedError | 16 |
An unexpected error occurred. |
kWebErrorStatusUnknown | 0 |
An unknown error occurred. |
Web Resource Context
Constant | Value | Description |
---|---|---|
kWebResourceContextAll | 0 |
All resources. |
kWebResourceContextCspViolationReport | 15 |
CSP Violation Reports. |
kWebResourceContextDocument | 1 |
Document resources. |
kWebResourceContextEventSource | 10 |
EventSource API communication. |
kWebResourceContextFetch | 8 |
Fetch API communication. |
kWebResourceContextFont | 5 |
Font resources. |
kWebResourceContextImage | 3 |
Image resources. |
kWebResourceContextManifest | 12 |
Web App Manifests. |
kWebResourceContextMedia | 4 |
Other media resources such as videos. |
kWebResourceContextOther | 16 |
Other resources. |
kWebResourceContextPing | 14 |
Ping requests. |
kWebResourceContextScript | 6 |
Script resources. |
kWebResourceContextSignedExchange | 13 |
Signed HTTP Exchanges. |
kWebResourceContextStylesheet | 2 |
CSS resources. |
kWebResourceContextTextTrack | 9 |
TextTrack resources. |
kWebResourceContextWebSocket | 11 |
WebSocket API communication. |
kWebResourceContextXMLHttpRequest | 7 |
XML HTTP requests. |
Some examples using this control:
Blog Entries
- WebView2 and Cookies in Xojo
- MBS Xojo Plugins, version 23.1pr4
- MonkeyBread Software Releases the MBS Xojo Plugins in version 22.2
- News from the MBS Xojo Plugins in version 21.5
- New desktop controls
- MonkeyBread Software Releases the MBS Xojo Plugins in version 21.4
- News from the MBS Xojo Plugins Version 21.1
- MonkeyBread Software Releases the MBS Xojo Plugins in version 21.1
- MonkeyBread Software Releases the MBS Xojo Plugins in version 21.0
- MBS Xojo Plugins, version 20.5pr8
Xojo Developer Magazine
The items on this page are in the following plugins: MBS WinFrameworks Plugin.
SCNIOSControlMBS - WKWebViewControlMBS
