The initial APIs of this component are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
The sample effect is subject to the actual device.
type WebviewController = import('../api/@ohos.web.webview').default.WebviewController
Defines methods for the web controller.
System capability: SystemCapability.Web.Webview.Core
| Type | Description |
|---|---|
| import('../api/@ohos.web.webview').default.WebviewController | Used to control the behavior of the Web component. A WebviewController object can control only one Web component. Methods (except static methods) on the WebviewController can be called only after the Web component is bound to the WebviewController. |
type OnAdsBlockedCallback = (details: AdsBlockedDetails) => void
Defines a callback invoked when ads are blocked on the web page.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| details | AdsBlockedDetails | Yes | Detailed information about the blocked ads when ads are blocked. |
type OnSslErrorEventCallback = (sslErrorEvent: SslErrorEvent) => void
Defines a callback invoked when an SSL error occurs during resource loading.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| sslErrorEvent | SslErrorEvent | Yes | Details about the callback invoked when an SSL error occurs during resource loading. |
type OnVerifyPinCallback = (verifyPinEvent: VerifyPinEvent) => void
Callback triggered to notify the user of PIN authentication.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| verifyPinEvent | VerifyPinEvent | Yes | Details of the callback triggered to notify the user of PIN authentication. |
type OnRenderProcessNotRespondingCallback = (data : RenderProcessNotRespondingData) => void
Defines a callback invoked when the rendering process does not respond.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| data | RenderProcessNotRespondingData | Yes | Detailed information about the unresponsive rendering process. |
type OnRenderProcessRespondingCallback = () => void
Defines a callback invoked when the rendering process transitions back to a normal operating state from an unresponsive state.
System capability: SystemCapability.Web.Webview.Core
type OnViewportFitChangedCallback = (viewportFit: ViewportFit) => void
Defines a callback invoked when the viewport-fit configuration in the web page's <meta> tag changes.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| viewportFit | ViewportFit | Yes | Viewport type for viewport-fit in the web page <meta> tag. |
type OnNativeEmbedVisibilityChangeCallback = (nativeEmbedVisibilityInfo: NativeEmbedVisibilityInfo) => void
Defines a callback invoked when the visibility of a same-layer tag changes.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| nativeEmbedVisibilityInfo | NativeEmbedVisibilityInfo | Yes | Visibility information about the same-layer tag. |
type OnFullScreenEnterCallback = (event: FullScreenEnterEvent) => void
Defines a callback invoked when the Web component enters full screen mode.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | FullScreenEnterEvent | Yes | Callback event for the Web component to enter full screen mode. |
type OnFirstMeaningfulPaintCallback = (firstMeaningfulPaint: FirstMeaningfulPaint) => void
Defines a callback invoked when the first meaningful paint occurs on the page.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| firstMeaningfulPaint | FirstMeaningfulPaint | Yes | Information about the first meaningful paint. |
type OnLargestContentfulPaintCallback = (largestContentfulPaint: LargestContentfulPaint) => void
Defines a callback invoked when the largest content paint occurs on the web page.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| largestContentfulPaint | LargestContentfulPaint | Yes | Information about the largest content paint. |
type OnSafeBrowsingCheckResultCallback = (threatType: ThreatType) => void
Defines a callback invoked by a website safe browsing check.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| threatType | ThreatType | Yes | Website threat type. |
type OnIntelligentTrackingPreventionCallback = (details: IntelligentTrackingPreventionDetails) => void
Defines a callback invoked when the tracker cookie is intercepted.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| details | IntelligentTrackingPreventionDetails | Yes | Detailed information about intelligent tracking prevention. |
type OnOverrideUrlLoadingCallback = (webResourceRequest: WebResourceRequest) => boolean
Defines a callback for onOverrideUrlLoading.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| webResourceRequest | WebResourceRequest | Yes | Information about the URL request. |
Return value
| Type | Description |
|---|---|
| boolean | Whether the loading is blocked. true is returned if the loading is blocked; otherwise, false is returned. |
type WebKeyboardCallback = (keyboardCallbackInfo: WebKeyboardCallbackInfo) => WebKeyboardOptions
Defines a callback to intercept the soft keyboard initiated from editable elements on a web page. This event is typically called when the <input> tag on the web page is clicked.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| keyboardCallbackInfo | WebKeyboardCallbackInfo | Yes | Input parameter of the callback used to intercept the soft keyboard initiated from editable elements on a web page, including WebKeyboardController and editable element attributes. |
Return value
| Type | Description |
|---|---|
| WebKeyboardOptions | WebKeyboardOptions instance, which is used to determine which type of soft keyboard to start by the ArkWeb kernel. |
type OnOverrideErrorPageCallback = (errorPageEvent: OnErrorReceiveEvent) => string
Defines a callback of onOverrideErrorPage. This callback is triggered when a web page fails to be loaded.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| errorPageEvent | OnErrorReceiveEvent | Yes | Information returned when an error occurs during web page loading. |
Return value
| Type | Description |
|---|---|
| string | Base64-encoded HTML text content. |
type MouseInfoCallback = (event: NativeEmbedMouseInfo) => void
Defines a callback triggered when a same-layer tag is clicked using the mouse or touchpad.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | NativeEmbedMouseInfo | Yes | Detailed information about clicking or touching and holding a same-layer tag using the mouse or touchpad. |
Example
For details about the sample code, see onNativeEmbedMouseEvent.
type OnNativeEmbedObjectParamChangeCallback = (event: NativeEmbedParamDataInfo) => void
Defines a callback triggered when the param element embedded in the same-layer rendered object tag is added, modified, or deleted.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | NativeEmbedParamDataInfo | Yes | Detailed information about the changes of the param element embedded in the object tag. |
Example
For details about the sample code, see onNativeEmbedObjectParamChange.
type OnDetectBlankScreenCallback = (event: BlankScreenDetectionEventInfo) => void
Defines a callback triggered when a blank screen is detected.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | BlankScreenDetectionEventInfo | Yes | Detailed information when a blank screen is detected. |
Example
For details about the sample code, see onDetectedBlankScreen.
type OnCameraCaptureStateChangeCallback = (event: CameraCaptureStateChangeInfo) => void;
Defines a callback triggered when the camera state of the page changes.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | CameraCaptureStateChangeInfo | Yes | Original and new camera state. |
type OnMicrophoneCaptureStateChangeCallback = (event: MicrophoneCaptureStateChangeInfo) => void;
Defines a callback triggered when the microphone state of the page changes.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| event | MicrophoneCaptureStateChangeInfo | Yes | Original and new microphone state. |
type TextSelectionChangeCallback = (selectionText: string) => void
Defines a callback triggered when the text selection changes.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| selectionText | string | Yes | Selected text. |
Example
For details about the complete sample code, see onTextSelectionChange.
type OnFirstScreenPaintCallback = (firstScreenPaint: FirstScreenPaint) => void
Defines a callback triggered when the first screen paint is complete.
System capability: SystemCapability.Web.Webview.Core
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| firstScreenPaint | FirstScreenPaint | Yes | Details about the first screen paint. |
Example
For details about the complete sample code, see onFirstScreenPaint.