1e41f4b71Sopenharmony_ci# Web
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **Web** component can be used to display web pages. It can be used with the [@ohos.web.webview](js-apis-webview.md) module, which provides APIs for web control.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> - You can preview how this component looks on a real device, but not in DevEco Studio Previewer.
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Required Permissions
11e41f4b71Sopenharmony_ciTo use online resources, the application must have the **ohos.permission.INTERNET** permission. For details about how to apply for a permission, see [Declaring Permissions](../../security/AccessToken/declare-permissions.md).
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## Child Components
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciNot supported
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## APIs
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciWeb(options: { src: ResourceStr, controller: WebviewController | WebController, renderMode? : RenderMode, incognitoMode? : boolean, sharedRenderProcessToken? : string})
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci> **NOTE**
22e41f4b71Sopenharmony_ci>
23e41f4b71Sopenharmony_ci> Transition animation is not supported.
24e41f4b71Sopenharmony_ci> **Web** components on the same page must be bound to different **WebviewController** instances.
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**Parameters**
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci| Name       | Type                                    | Mandatory  | Description                                    |
29e41f4b71Sopenharmony_ci| ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
30e41f4b71Sopenharmony_ci| src        | [ResourceStr](../apis-arkui/arkui-ts/ts-types.md#resourcestr)   | Yes   | Address of a web page resource. To access local resource files, use the **$rawfile** or **resource** protocol. To load a local resource file (in HTML or TXT format) in the sandbox outside of the application package, use **file://** to specify the path of the sandbox.<br>**src** cannot be dynamically changed through a state variable (for example, @State). To change the value, call [loadUrl()](js-apis-webview.md#loadurl).|
31e41f4b71Sopenharmony_ci| controller | [WebviewController<sup>9+</sup>](js-apis-webview.md#webviewcontroller) \| [WebController](#webcontroller) | Yes   | Controller. This API is deprecated since API version 9. You are advised to use **WebviewController** instead.|
32e41f4b71Sopenharmony_ci| renderMode<sup>12+</sup> | [RenderMode](#rendermode12)| No  | Rendering mode.<br>**RenderMode.ASYNC_RENDER** (default, cannot be dynamically adjusted): The **Web** component is rendered asynchronously.<br>**RenderMode.SYNC_RENDER**: The **Web** component is rendered synchronously within the current execution context.|
33e41f4b71Sopenharmony_ci| incognitoMode<sup>11+</sup> | boolean | No| Whether to enable incognito mode. The value **true** means to enable incognito mode, and **false** means the opposite.<br> Default value: **false**|
34e41f4b71Sopenharmony_ci| sharedRenderProcessToken<sup>12+</sup> | string | No| The token of the shared rendering process specified by the **Web** component. In multi-rendering process mode, the **Web** component with the same token preferentially attempts to reuse the rendering process bound to the token. The token is bound to the rendering process when the rendering process is initialized. When the rendering process is not associated with a **Web** component, its binding to the token is removed.<br> Default value: **""** |
35e41f4b71Sopenharmony_ci**Example**
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ciExample of loading online web pages:
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci  ```ts
40e41f4b71Sopenharmony_ci  // xxx.ets
41e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci  @Entry
44e41f4b71Sopenharmony_ci  @Component
45e41f4b71Sopenharmony_ci  struct WebComponent {
46e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci    build() {
49e41f4b71Sopenharmony_ci      Column() {
50e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
51e41f4b71Sopenharmony_ci      }
52e41f4b71Sopenharmony_ci    }
53e41f4b71Sopenharmony_ci  }
54e41f4b71Sopenharmony_ci  ```
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ciExample of loading online web pages in incognito mode:
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci  ```ts
59e41f4b71Sopenharmony_ci  // xxx.ets
60e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci  @Entry
63e41f4b71Sopenharmony_ci  @Component
64e41f4b71Sopenharmony_ci  struct WebComponent {
65e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci    build() {
68e41f4b71Sopenharmony_ci      Column() {
69e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller, incognitoMode: true })
70e41f4b71Sopenharmony_ci      }
71e41f4b71Sopenharmony_ci    }
72e41f4b71Sopenharmony_ci  }
73e41f4b71Sopenharmony_ci  ```
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ciExample of rendering the **Web** component synchronously within the current execution context:
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci  ```ts
78e41f4b71Sopenharmony_ci  // xxx.ets
79e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci  @Entry
82e41f4b71Sopenharmony_ci  @Component
83e41f4b71Sopenharmony_ci  struct WebComponent {
84e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci    build() {
87e41f4b71Sopenharmony_ci      Column() {
88e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller, renderMode: RenderMode.SYNC_RENDER })
89e41f4b71Sopenharmony_ci      }
90e41f4b71Sopenharmony_ci    }
91e41f4b71Sopenharmony_ci  }
92e41f4b71Sopenharmony_ci  ```
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ciExample of using the **Web** component to specify the shared rendering process.
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci   ```ts
97e41f4b71Sopenharmony_ci  // xxx.ets
98e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci  @Entry
101e41f4b71Sopenharmony_ci  @Component
102e41f4b71Sopenharmony_ci  struct WebComponent {
103e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci    build() {
106e41f4b71Sopenharmony_ci      Column() {
107e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller, sharedRenderProcessToken: "111" })
108e41f4b71Sopenharmony_ci        Web({ src: 'www.w3.org', controller: this.controller, sharedRenderProcessToken: "111" })
109e41f4b71Sopenharmony_ci      }
110e41f4b71Sopenharmony_ci    }
111e41f4b71Sopenharmony_ci  }
112e41f4b71Sopenharmony_ci  ```
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ciExample of loading local web pages:
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci  ```ts
117e41f4b71Sopenharmony_ci  // xxx.ets
118e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci  @Entry
121e41f4b71Sopenharmony_ci  @Component
122e41f4b71Sopenharmony_ci  struct WebComponent {
123e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci    build() {
126e41f4b71Sopenharmony_ci      Column() {
127e41f4b71Sopenharmony_ci        // Load a local resource file through $rawfile.
128e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
129e41f4b71Sopenharmony_ci      }
130e41f4b71Sopenharmony_ci    }
131e41f4b71Sopenharmony_ci  }
132e41f4b71Sopenharmony_ci  ```
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci  ```ts
135e41f4b71Sopenharmony_ci  // xxx.ets
136e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci  @Entry
139e41f4b71Sopenharmony_ci  @Component
140e41f4b71Sopenharmony_ci  struct WebComponent {
141e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci    build() {
144e41f4b71Sopenharmony_ci      Column() {
145e41f4b71Sopenharmony_ci        // Load a local resource file through the resource protocol.
146e41f4b71Sopenharmony_ci        Web({ src: "resource://rawfile/index.html", controller: this.controller })
147e41f4b71Sopenharmony_ci      }
148e41f4b71Sopenharmony_ci    }
149e41f4b71Sopenharmony_ci  }
150e41f4b71Sopenharmony_ci  ```
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ciExample of loading local resource files in the sandbox:
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci1. Obtain the sandbox path through the constructed singleton object **GlobalContext**.
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci   ```ts
157e41f4b71Sopenharmony_ci   // GlobalContext.ets
158e41f4b71Sopenharmony_ci   export class GlobalContext {
159e41f4b71Sopenharmony_ci     private constructor() {}
160e41f4b71Sopenharmony_ci     private static instance: GlobalContext;
161e41f4b71Sopenharmony_ci     private _objects = new Map<string, Object>();
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci     public static getContext(): GlobalContext {
164e41f4b71Sopenharmony_ci       if (!GlobalContext.instance) {
165e41f4b71Sopenharmony_ci         GlobalContext.instance = new GlobalContext();
166e41f4b71Sopenharmony_ci       }
167e41f4b71Sopenharmony_ci       return GlobalContext.instance;
168e41f4b71Sopenharmony_ci     }
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci     getObject(value: string): Object | undefined {
171e41f4b71Sopenharmony_ci       return this._objects.get(value);
172e41f4b71Sopenharmony_ci     }
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci     setObject(key: string, objectClass: Object): void {
175e41f4b71Sopenharmony_ci       this._objects.set(key, objectClass);
176e41f4b71Sopenharmony_ci     }
177e41f4b71Sopenharmony_ci   }
178e41f4b71Sopenharmony_ci   ```
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci   ```ts
181e41f4b71Sopenharmony_ci   // xxx.ets
182e41f4b71Sopenharmony_ci   import { webview } from '@kit.ArkWeb';
183e41f4b71Sopenharmony_ci   import { GlobalContext } from '../GlobalContext';
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci   let url = 'file://' + GlobalContext.getContext().getObject("filesDir") + '/index.html';
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci   @Entry
188e41f4b71Sopenharmony_ci   @Component
189e41f4b71Sopenharmony_ci   struct WebComponent {
190e41f4b71Sopenharmony_ci     controller: webview.WebviewController = new webview.WebviewController();
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci     build() {
193e41f4b71Sopenharmony_ci       Column() {
194e41f4b71Sopenharmony_ci         // Load the files in the sandbox.
195e41f4b71Sopenharmony_ci         Web({ src: url, controller: this.controller })
196e41f4b71Sopenharmony_ci       }
197e41f4b71Sopenharmony_ci     }
198e41f4b71Sopenharmony_ci   }
199e41f4b71Sopenharmony_ci   ```
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci2. Modify the **EntryAbility.ets** file.
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci   The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci   ```ts
206e41f4b71Sopenharmony_ci   // xxx.ets
207e41f4b71Sopenharmony_ci   import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
208e41f4b71Sopenharmony_ci   import { webview } from '@kit.ArkWeb';
209e41f4b71Sopenharmony_ci   import { GlobalContext } from '../GlobalContext';
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci   export default class EntryAbility extends UIAbility {
212e41f4b71Sopenharmony_ci     onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
213e41f4b71Sopenharmony_ci       // Data synchronization between the UIAbility component and UI can be implemented by binding filesDir to the GlobalContext object.
214e41f4b71Sopenharmony_ci       GlobalContext.getContext().setObject("filesDir", this.context.filesDir);
215e41f4b71Sopenharmony_ci       console.log("Sandbox path is " + GlobalContext.getContext().getObject("filesDir"));
216e41f4b71Sopenharmony_ci     }
217e41f4b71Sopenharmony_ci   }
218e41f4b71Sopenharmony_ci   ```
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci   HTML file to be loaded:
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci   ```html
223e41f4b71Sopenharmony_ci   <!-- index.html -->
224e41f4b71Sopenharmony_ci   <!DOCTYPE html>
225e41f4b71Sopenharmony_ci   <html>
226e41f4b71Sopenharmony_ci       <body>
227e41f4b71Sopenharmony_ci           <p>Hello World</p>
228e41f4b71Sopenharmony_ci       </body>
229e41f4b71Sopenharmony_ci   </html>
230e41f4b71Sopenharmony_ci   ```
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci## Attributes
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ciThe following universal attributes are supported: [aspectRatio](../apis-arkui/arkui-ts/ts-universal-attributes-layout-constraints.md#aspectratio), [backdropBlur](../apis-arkui/arkui-ts/ts-universal-attributes-image-effect.md#backdropblur), [backgroundColor](../apis-arkui/arkui-ts/ts-universal-attributes-background.md#backgroundcolor), [bindContentCover](../apis-arkui/arkui-ts/ts-universal-attributes-modal-transition.md#bindcontentcover), [bindContextMenu](../apis-arkui/arkui-ts/ts-universal-attributes-menu.md#bindcontextmenu8), [bindMenu](../apis-arkui/arkui-ts/ts-universal-attributes-menu.md#bindmenu), [bindSheet](../apis-arkui/arkui-ts/ts-universal-attributes-sheet-transition.md#bindsheet), [borderColor](../apis-arkui/arkui-ts/ts-universal-attributes-border.md#bordercolor), [borderRadius](../apis-arkui/arkui-ts/ts-universal-attributes-border.md#borderradius), [borderStyle](../apis-arkui/arkui-ts/ts-universal-attributes-border.md#borderstyle), [borderWidth](../apis-arkui/arkui-ts/ts-universal-attributes-border.md#borderwidth), [clip](../apis-arkui/arkui-ts/ts-universal-attributes-sharp-clipping.md#clip), [constraintSize](../apis-arkui/arkui-ts/ts-universal-attributes-size.md#constraintsize), [defaultFocus](../apis-arkui/arkui-ts/ts-universal-attributes-focus.md#defaultfocus9), [focusable](../apis-arkui/arkui-ts/ts-universal-attributes-focus.md#focusable), [tabIndex](../apis-arkui/arkui-ts/ts-universal-attributes-focus.md#tabindex9), [groupDefaultFocus](../apis-arkui/arkui-ts/ts-universal-attributes-focus.md#groupdefaultfocus9), [focusOnTouch](../apis-arkui/arkui-ts/ts-universal-attributes-focus.md#focusontouch9), [displayPriority](../apis-arkui/arkui-ts/ts-universal-attributes-layout-constraints.md#displaypriority), [enabled](../apis-arkui/arkui-ts/ts-universal-attributes-enable.md#enabled), [flexBasis](../apis-arkui/arkui-ts/ts-universal-attributes-flex-layout.md#flexbasis), [flexGrow](../apis-arkui/arkui-ts/ts-universal-attributes-flex-layout.md#flexgrow), [flexShrink](../apis-arkui/arkui-ts/ts-universal-attributes-flex-layout.md#flexshrink), [layoutWeight](../apis-arkui/arkui-ts/ts-universal-attributes-size.md#layoutweight), [id](../apis-arkui/arkui-ts/ts-universal-attributes-component-id.md), [gridOffset](../apis-arkui/arkui-ts/ts-universal-attributes-grid.md), [gridSpan](../apis-arkui/arkui-ts/ts-universal-attributes-grid.md), [useSizeType](../apis-arkui/arkui-ts/ts-universal-attributes-grid.md), [height](../apis-arkui/arkui-ts/ts-universal-attributes-size.md#height), [touchable](../apis-arkui/arkui-ts/ts-universal-attributes-click.md), [margin](../apis-arkui/arkui-ts/ts-universal-attributes-size.md#margin), [markAnchor](../apis-arkui/arkui-ts/ts-universal-attributes-location.md#markanchor), [offset](../apis-arkui/arkui-ts/ts-universal-attributes-location.md#offset), [width](../apis-arkui/arkui-ts/ts-universal-attributes-size.md#width), [zIndex](../apis-arkui/arkui-ts/ts-universal-attributes-z-order.md#zindex), [visibility](../apis-arkui/arkui-ts/ts-universal-attributes-visibility.md#visibility), [scale](../apis-arkui/arkui-ts/ts-universal-attributes-transformation.md#scale), [translate](../apis-arkui/arkui-ts/ts-universal-attributes-transformation.md#translate), [responseRegion](../apis-arkui/arkui-ts/ts-universal-attributes-touch-target.md#responseregion), [size](../apis-arkui/arkui-ts/ts-universal-attributes-size.md#size), [stateStyles](../apis-arkui/arkui-ts/ts-universal-attributes-polymorphic-style.md#statestyles), [opacity](../apis-arkui/arkui-ts/ts-universal-attributes-opacity.md#opacity), [shadow](../apis-arkui/arkui-ts/ts-universal-attributes-image-effect.md#shadow), [sharedTransition](../apis-arkui/arkui-ts/ts-transition-animation-shared-elements.md), [transition](../apis-arkui/arkui-ts/ts-transition-animation-component.md)
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci### domStorageAccess
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_cidomStorageAccess(domStorageAccess: boolean)
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ciSets whether to enable the DOM Storage API. By default, this feature is disabled.
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Web.Webview.Core
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci**Parameters**
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci| Name             | Type   | Mandatory  | Default Value  | Description                                |
247e41f4b71Sopenharmony_ci| ---------------- | ------- | ---- | ----- | ------------------------------------ |
248e41f4b71Sopenharmony_ci| domStorageAccess | boolean | Yes   | false | Whether to enable the DOM Storage API.|
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci**Example**
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci  ```ts
253e41f4b71Sopenharmony_ci  // xxx.ets
254e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci  @Entry
257e41f4b71Sopenharmony_ci  @Component
258e41f4b71Sopenharmony_ci  struct WebComponent {
259e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci    build() {
262e41f4b71Sopenharmony_ci      Column() {
263e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
264e41f4b71Sopenharmony_ci          .domStorageAccess(true)
265e41f4b71Sopenharmony_ci      }
266e41f4b71Sopenharmony_ci    }
267e41f4b71Sopenharmony_ci  }
268e41f4b71Sopenharmony_ci  ```
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci### fileAccess
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_cifileAccess(fileAccess: boolean)
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ciSets whether to enable access to the file system in the application. This setting does not affect the access to the files specified through [$rawfile(filepath/filename)](../../quick-start/resource-categories-and-access.md).
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci**fileAccess** is disabled by default since API version 12. When **fileAccess** is set to **false**, files in the read-only **/data/storage/el1/bundle/entry/resources/resfile** directory can still be accessed through the **file** protocol.
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci**Parameters**
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci| Name       | Type   | Mandatory  | Default Value | Description                  |
281e41f4b71Sopenharmony_ci| ---------- | ------- | ---- | ---- | ---------------------- |
282e41f4b71Sopenharmony_ci| fileAccess | boolean | Yes   | false | Whether to enable access to the file system in the application.<br>Default value:<br>API version 11 and earlier: **true**<br> API version 12 and later: **false**|
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci**Example**
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci  ```ts
287e41f4b71Sopenharmony_ci  // xxx.ets
288e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci  @Entry
291e41f4b71Sopenharmony_ci  @Component
292e41f4b71Sopenharmony_ci  struct WebComponent {
293e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci    build() {
296e41f4b71Sopenharmony_ci      Column() {
297e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
298e41f4b71Sopenharmony_ci          .fileAccess(true)
299e41f4b71Sopenharmony_ci      }
300e41f4b71Sopenharmony_ci    }
301e41f4b71Sopenharmony_ci  }
302e41f4b71Sopenharmony_ci  ```
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci### imageAccess
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ciimageAccess(imageAccess: boolean)
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ciSets whether to enable automatic image loading. By default, this feature is enabled.
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci**Parameters**
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci| Name        | Type   | Mandatory  | Default Value | Description           |
313e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | ---- | --------------- |
314e41f4b71Sopenharmony_ci| imageAccess | boolean | Yes   | true | Whether to enable automatic image loading.|
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci**Example**
317e41f4b71Sopenharmony_ci  ```ts
318e41f4b71Sopenharmony_ci  // xxx.ets
319e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci  @Entry
322e41f4b71Sopenharmony_ci  @Component
323e41f4b71Sopenharmony_ci  struct WebComponent {
324e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci    build() {
327e41f4b71Sopenharmony_ci      Column() {
328e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
329e41f4b71Sopenharmony_ci          .imageAccess(true)
330e41f4b71Sopenharmony_ci      }
331e41f4b71Sopenharmony_ci    }
332e41f4b71Sopenharmony_ci  }
333e41f4b71Sopenharmony_ci  ```
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci### javaScriptProxy
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_cijavaScriptProxy(javaScriptProxy: JavaScriptProxy)
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ciRegisters a JavaScript object with the window. APIs of this object can then be invoked in the window. The parameters cannot be updated. This API can be used in synchronous or asynchronous mode, or in both modes. If the API can be used in both synchronous and asynchronous modes, it is called asynchronously by default. Only one object can be registered through this API. To register multiple objects, use [registerJavaScriptProxy<sup>9+</sup>](js-apis-webview.md#registerjavascriptproxy).
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**Parameters**
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci| Name       | Type                                    | Mandatory  | Description                                    |
344e41f4b71Sopenharmony_ci| ---------- | ---------------------------------------- | ---- |---------------------------------------- |
345e41f4b71Sopenharmony_ci| javaScriptProxy     | [JavaScriptProxy](#javascriptproxy12)                                   | Yes   |  Object to be registered. Methods can be declared, but attributes cannot.                  |
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci**Example**
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci  ```ts
350e41f4b71Sopenharmony_ci  // xxx.ets
351e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci  class TestObj {
354e41f4b71Sopenharmony_ci    constructor() {
355e41f4b71Sopenharmony_ci    }
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci    test(data1: string, data2: string, data3: string): string {
358e41f4b71Sopenharmony_ci      console.log("data1:" + data1);
359e41f4b71Sopenharmony_ci      console.log("data2:" + data2);
360e41f4b71Sopenharmony_ci      console.log("data3:" + data3);
361e41f4b71Sopenharmony_ci      return "AceString";
362e41f4b71Sopenharmony_ci    }
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci    asyncTest(data: string): void {
365e41f4b71Sopenharmony_ci      console.log("async data:" + data);
366e41f4b71Sopenharmony_ci    }
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci    toString(): void {
369e41f4b71Sopenharmony_ci      console.log('toString' + "interface instead.");
370e41f4b71Sopenharmony_ci    }
371e41f4b71Sopenharmony_ci  }
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ci  @Entry
374e41f4b71Sopenharmony_ci  @Component
375e41f4b71Sopenharmony_ci  struct WebComponent {
376e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
377e41f4b71Sopenharmony_ci    testObj = new TestObj();
378e41f4b71Sopenharmony_ci    build() {
379e41f4b71Sopenharmony_ci      Column() {
380e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
381e41f4b71Sopenharmony_ci          .javaScriptAccess(true)
382e41f4b71Sopenharmony_ci          .javaScriptProxy({
383e41f4b71Sopenharmony_ci            object: this.testObj,
384e41f4b71Sopenharmony_ci            name: "objName",
385e41f4b71Sopenharmony_ci            methodList: ["test", "toString"],
386e41f4b71Sopenharmony_ci            asyncMethodList: ["asyncTest"],
387e41f4b71Sopenharmony_ci            controller: this.controller,
388e41f4b71Sopenharmony_ci        })
389e41f4b71Sopenharmony_ci      }
390e41f4b71Sopenharmony_ci    }
391e41f4b71Sopenharmony_ci  }
392e41f4b71Sopenharmony_ci  ```
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci### javaScriptAccess
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_cijavaScriptAccess(javaScriptAccess: boolean)
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ciSets whether JavaScript scripts can be executed. By default, JavaScript scripts can be executed.
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci**Parameters**
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci| Name             | Type   | Mandatory  | Default Value | Description               |
403e41f4b71Sopenharmony_ci| ---------------- | ------- | ---- | ---- | ------------------- |
404e41f4b71Sopenharmony_ci| javaScriptAccess | boolean | Yes   | true | Whether JavaScript scripts can be executed.|
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci**Example**
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci  ```ts
409e41f4b71Sopenharmony_ci  // xxx.ets
410e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci  @Entry
413e41f4b71Sopenharmony_ci  @Component
414e41f4b71Sopenharmony_ci  struct WebComponent {
415e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
416e41f4b71Sopenharmony_ci    build() {
417e41f4b71Sopenharmony_ci      Column() {
418e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
419e41f4b71Sopenharmony_ci          .javaScriptAccess(true)
420e41f4b71Sopenharmony_ci      }
421e41f4b71Sopenharmony_ci    }
422e41f4b71Sopenharmony_ci  }
423e41f4b71Sopenharmony_ci  ```
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci### overScrollMode<sup>11+</sup>
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_cioverScrollMode(mode: OverScrollMode)
428e41f4b71Sopenharmony_ci
429e41f4b71Sopenharmony_ciSets the overscroll mode, which is disabled by default. When the overscroll mode is enabled and the boundary of the scrolling area is reached, the **Web** component plays a bounce effect animation.
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci**Parameters**
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ci| Name | Type                                   | Mandatory  | Default Value                 | Description              |
434e41f4b71Sopenharmony_ci| ---- | --------------------------------------- | ---- | -------------------- | ------------------ |
435e41f4b71Sopenharmony_ci| mode | [OverScrollMode](#overscrollmode11) | Yes   | OverScrollMode.NEVER | Whether to enable the overscroll mode.|
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci**Example**
438e41f4b71Sopenharmony_ci
439e41f4b71Sopenharmony_ci  ```ts
440e41f4b71Sopenharmony_ci  // xxx.ets
441e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci  @Entry
444e41f4b71Sopenharmony_ci  @Component
445e41f4b71Sopenharmony_ci  struct WebComponent {
446e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
447e41f4b71Sopenharmony_ci    @State mode: OverScrollMode = OverScrollMode.ALWAYS;
448e41f4b71Sopenharmony_ci    build() {
449e41f4b71Sopenharmony_ci      Column() {
450e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
451e41f4b71Sopenharmony_ci          .overScrollMode(this.mode)
452e41f4b71Sopenharmony_ci      }
453e41f4b71Sopenharmony_ci    }
454e41f4b71Sopenharmony_ci  }
455e41f4b71Sopenharmony_ci  ```
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ci### mixedMode
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_cimixedMode(mixedMode: MixedMode)
460e41f4b71Sopenharmony_ci
461e41f4b71Sopenharmony_ciSets whether to enable loading of HTTP and HTTPS hybrid content can be loaded. By default, this feature is disabled.
462e41f4b71Sopenharmony_ci
463e41f4b71Sopenharmony_ci**Parameters**
464e41f4b71Sopenharmony_ci
465e41f4b71Sopenharmony_ci| Name      | Type                       | Mandatory  | Default Value           | Description     |
466e41f4b71Sopenharmony_ci| --------- | --------------------------- | ---- | -------------- | --------- |
467e41f4b71Sopenharmony_ci| mixedMode | [MixedMode](#mixedmode)| Yes   | MixedMode.None | Mixed content to load.|
468e41f4b71Sopenharmony_ci
469e41f4b71Sopenharmony_ci**Example**
470e41f4b71Sopenharmony_ci
471e41f4b71Sopenharmony_ci  ```ts
472e41f4b71Sopenharmony_ci  // xxx.ets
473e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
474e41f4b71Sopenharmony_ci
475e41f4b71Sopenharmony_ci  @Entry
476e41f4b71Sopenharmony_ci  @Component
477e41f4b71Sopenharmony_ci  struct WebComponent {
478e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
479e41f4b71Sopenharmony_ci    @State mode: MixedMode = MixedMode.All;
480e41f4b71Sopenharmony_ci    build() {
481e41f4b71Sopenharmony_ci      Column() {
482e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
483e41f4b71Sopenharmony_ci          .mixedMode(this.mode)
484e41f4b71Sopenharmony_ci      }
485e41f4b71Sopenharmony_ci    }
486e41f4b71Sopenharmony_ci  }
487e41f4b71Sopenharmony_ci  ```
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci### onlineImageAccess
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_cionlineImageAccess(onlineImageAccess: boolean)
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ciSets whether to enable access to online images through HTTP and HTTPS. By default, this feature is enabled.
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci**Parameters**
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci| Name              | Type   | Mandatory  | Default Value | Description            |
498e41f4b71Sopenharmony_ci| ----------------- | ------- | ---- | ---- | ---------------- |
499e41f4b71Sopenharmony_ci| onlineImageAccess | boolean | Yes   | true | Whether to enable access to online images through HTTP and HTTPS.|
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci**Example**
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci  ```ts
504e41f4b71Sopenharmony_ci  // xxx.ets
505e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
506e41f4b71Sopenharmony_ci
507e41f4b71Sopenharmony_ci  @Entry
508e41f4b71Sopenharmony_ci  @Component
509e41f4b71Sopenharmony_ci  struct WebComponent {
510e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci    build() {
513e41f4b71Sopenharmony_ci      Column() {
514e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
515e41f4b71Sopenharmony_ci          .onlineImageAccess(true)
516e41f4b71Sopenharmony_ci      }
517e41f4b71Sopenharmony_ci    }
518e41f4b71Sopenharmony_ci  }
519e41f4b71Sopenharmony_ci  ```
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ci### zoomAccess
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_cizoomAccess(zoomAccess: boolean)
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ciSets whether to enable zoom gestures. By default, this feature is enabled.
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci**Parameters**
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci| Name       | Type   | Mandatory  | Default Value | Description         |
530e41f4b71Sopenharmony_ci| ---------- | ------- | ---- | ---- | ------------- |
531e41f4b71Sopenharmony_ci| zoomAccess | boolean | Yes   | true | Whether to enable zoom gestures.|
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci**Example**
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci  ```ts
536e41f4b71Sopenharmony_ci  // xxx.ets
537e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci  @Entry
540e41f4b71Sopenharmony_ci  @Component
541e41f4b71Sopenharmony_ci  struct WebComponent {
542e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci    build() {
545e41f4b71Sopenharmony_ci      Column() {
546e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
547e41f4b71Sopenharmony_ci          .zoomAccess(true)
548e41f4b71Sopenharmony_ci      }
549e41f4b71Sopenharmony_ci    }
550e41f4b71Sopenharmony_ci  }
551e41f4b71Sopenharmony_ci  ```
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci### overviewModeAccess
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_cioverviewModeAccess(overviewModeAccess: boolean)
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ciSets whether to load web pages by using the overview mode. By default, this feature is enabled. Currently, only mobile devices are supported.
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_ci**Parameters**
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_ci| Name               | Type   | Mandatory  | Default Value | Description           |
562e41f4b71Sopenharmony_ci| ------------------ | ------- | ---- | ---- | --------------- |
563e41f4b71Sopenharmony_ci| overviewModeAccess | boolean | Yes   | true | Whether to load web pages by using the overview mode.|
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_ci**Example**
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ci  ```ts
568e41f4b71Sopenharmony_ci  // xxx.ets
569e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
570e41f4b71Sopenharmony_ci
571e41f4b71Sopenharmony_ci  @Entry
572e41f4b71Sopenharmony_ci  @Component
573e41f4b71Sopenharmony_ci  struct WebComponent {
574e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
575e41f4b71Sopenharmony_ci
576e41f4b71Sopenharmony_ci    build() {
577e41f4b71Sopenharmony_ci      Column() {
578e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
579e41f4b71Sopenharmony_ci          .overviewModeAccess(true)
580e41f4b71Sopenharmony_ci      }
581e41f4b71Sopenharmony_ci    }
582e41f4b71Sopenharmony_ci  }
583e41f4b71Sopenharmony_ci  ```
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci### databaseAccess
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_cidatabaseAccess(databaseAccess: boolean)
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ciSets whether to enable database access. By default, this feature is disabled.
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci**Parameters**
592e41f4b71Sopenharmony_ci
593e41f4b71Sopenharmony_ci| Name           | Type   | Mandatory  | Default Value  | Description             |
594e41f4b71Sopenharmony_ci| -------------- | ------- | ---- | ----- | ----------------- |
595e41f4b71Sopenharmony_ci| databaseAccess | boolean | Yes   | false | Whether to enable database access.|
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_ci**Example**
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci  ```ts
600e41f4b71Sopenharmony_ci  // xxx.ets
601e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci  @Entry
604e41f4b71Sopenharmony_ci  @Component
605e41f4b71Sopenharmony_ci  struct WebComponent {
606e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ci    build() {
609e41f4b71Sopenharmony_ci      Column() {
610e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
611e41f4b71Sopenharmony_ci          .databaseAccess(true)
612e41f4b71Sopenharmony_ci      }
613e41f4b71Sopenharmony_ci    }
614e41f4b71Sopenharmony_ci  }
615e41f4b71Sopenharmony_ci  ```
616e41f4b71Sopenharmony_ci
617e41f4b71Sopenharmony_ci### geolocationAccess
618e41f4b71Sopenharmony_ci
619e41f4b71Sopenharmony_cigeolocationAccess(geolocationAccess: boolean)
620e41f4b71Sopenharmony_ci
621e41f4b71Sopenharmony_ciSets whether to enable geolocation access. By default, this feature is enabled. For details, see [Managing Location Permissions](../../web/web-geolocation-permission.md).
622e41f4b71Sopenharmony_ci
623e41f4b71Sopenharmony_ci**Parameters**
624e41f4b71Sopenharmony_ci
625e41f4b71Sopenharmony_ci| Name              | Type   | Mandatory  | Default Value | Description           |
626e41f4b71Sopenharmony_ci| ----------------- | ------- | ---- | ---- | --------------- |
627e41f4b71Sopenharmony_ci| geolocationAccess | boolean | Yes   | true | Whether to enable geolocation access.|
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ci**Example**
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ci  ```ts
632e41f4b71Sopenharmony_ci  // xxx.ets
633e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci  @Entry
636e41f4b71Sopenharmony_ci  @Component
637e41f4b71Sopenharmony_ci  struct WebComponent {
638e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ci    build() {
641e41f4b71Sopenharmony_ci      Column() {
642e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
643e41f4b71Sopenharmony_ci          .geolocationAccess(true)
644e41f4b71Sopenharmony_ci      }
645e41f4b71Sopenharmony_ci    }
646e41f4b71Sopenharmony_ci  }
647e41f4b71Sopenharmony_ci  ```
648e41f4b71Sopenharmony_ci
649e41f4b71Sopenharmony_ci### mediaPlayGestureAccess
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_cimediaPlayGestureAccess(access: boolean)
652e41f4b71Sopenharmony_ci
653e41f4b71Sopenharmony_ciSets whether video playback must be started by user gestures. This API is not applicable to videos that do not have an audio track or whose audio track is muted.
654e41f4b71Sopenharmony_ci
655e41f4b71Sopenharmony_ci**Parameters**
656e41f4b71Sopenharmony_ci
657e41f4b71Sopenharmony_ci| Name   | Type   | Mandatory  | Default Value | Description               |
658e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ---- | ------------------- |
659e41f4b71Sopenharmony_ci| access | boolean | Yes   | true | Whether video playback must be started by user gestures.|
660e41f4b71Sopenharmony_ci
661e41f4b71Sopenharmony_ci**Example**
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci  ```ts
664e41f4b71Sopenharmony_ci  // xxx.ets
665e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ci  @Entry
668e41f4b71Sopenharmony_ci  @Component
669e41f4b71Sopenharmony_ci  struct WebComponent {
670e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
671e41f4b71Sopenharmony_ci    @State access: boolean = true;
672e41f4b71Sopenharmony_ci
673e41f4b71Sopenharmony_ci    build() {
674e41f4b71Sopenharmony_ci      Column() {
675e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
676e41f4b71Sopenharmony_ci          .mediaPlayGestureAccess(this.access)
677e41f4b71Sopenharmony_ci      }
678e41f4b71Sopenharmony_ci    }
679e41f4b71Sopenharmony_ci  }
680e41f4b71Sopenharmony_ci  ```
681e41f4b71Sopenharmony_ci
682e41f4b71Sopenharmony_ci### multiWindowAccess<sup>9+</sup>
683e41f4b71Sopenharmony_ci
684e41f4b71Sopenharmony_cimultiWindowAccess(multiWindow: boolean)
685e41f4b71Sopenharmony_ci
686e41f4b71Sopenharmony_ciSets whether to enable the multi-window permission. By default, this feature is disabled.
687e41f4b71Sopenharmony_ciEnabling the multi-window permission requires implementation of the **onWindowNew** event. For the sample code, see [onWindowNew](#onwindownew9).
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci**Parameters**
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ci| Name        | Type   | Mandatory  | Default Value  | Description        |
692e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | ----- | ------------ |
693e41f4b71Sopenharmony_ci| multiWindow | boolean | Yes   | false | Whether to enable the multi-window permission.|
694e41f4b71Sopenharmony_ci
695e41f4b71Sopenharmony_ci**Example**
696e41f4b71Sopenharmony_ci
697e41f4b71Sopenharmony_ci  ```ts
698e41f4b71Sopenharmony_ci  // xxx.ets
699e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_ci  @Entry
702e41f4b71Sopenharmony_ci  @Component
703e41f4b71Sopenharmony_ci  struct WebComponent {
704e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_ci    build() {
707e41f4b71Sopenharmony_ci      Column() {
708e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
709e41f4b71Sopenharmony_ci        .multiWindowAccess(false)
710e41f4b71Sopenharmony_ci      }
711e41f4b71Sopenharmony_ci    }
712e41f4b71Sopenharmony_ci  }
713e41f4b71Sopenharmony_ci  ```
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ci### horizontalScrollBarAccess<sup>9+</sup>
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_cihorizontalScrollBarAccess(horizontalScrollBar: boolean)
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ciSets whether to display the horizontal scrollbar, including the default system scrollbar and custom scrollbar. By default, the horizontal scrollbar is displayed.
720e41f4b71Sopenharmony_ci> **NOTE**
721e41f4b71Sopenharmony_ci>
722e41f4b71Sopenharmony_ci> - If an @State decorated variable is used to control the horizontal scrollbar visibility, **controller.refresh()** must be called for the settings to take effect.
723e41f4b71Sopenharmony_ci> - If the horizontal scrollbar visibility changes frequently through an @State decorated variable, it is recommended that the variable correspond to the **Web** component one by one.
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ci**Parameters**
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci| Name                | Type   | Mandatory  | Default Value | Description        |
728e41f4b71Sopenharmony_ci| ------------------- | ------- | ---- | ---- | ------------ |
729e41f4b71Sopenharmony_ci| horizontalScrollBar | boolean | Yes   | true | Whether to display the horizontal scrollbar.|
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**Example**
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci  ```ts
734e41f4b71Sopenharmony_ci  // xxx.ets
735e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
736e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
737e41f4b71Sopenharmony_ci
738e41f4b71Sopenharmony_ci  @Entry
739e41f4b71Sopenharmony_ci  @Component
740e41f4b71Sopenharmony_ci  struct WebComponent {
741e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
742e41f4b71Sopenharmony_ci    @State isShow: boolean = false;
743e41f4b71Sopenharmony_ci
744e41f4b71Sopenharmony_ci    build() {
745e41f4b71Sopenharmony_ci      Column() {
746e41f4b71Sopenharmony_ci        // If an @State decorated variable is used to control the horizontal scrollbar visibility, controller.refresh() must be called for the settings to take effect.
747e41f4b71Sopenharmony_ci        Button('refresh')
748e41f4b71Sopenharmony_ci          .onClick(() => {
749e41f4b71Sopenharmony_ci            this.isShow = true;
750e41f4b71Sopenharmony_ci            try {
751e41f4b71Sopenharmony_ci              this.controller.refresh();
752e41f4b71Sopenharmony_ci            } catch (error) {
753e41f4b71Sopenharmony_ci              console.error(`ErrorCode: ${(error as BusinessError).code},  Message: ${(error as BusinessError).message}`);
754e41f4b71Sopenharmony_ci            }
755e41f4b71Sopenharmony_ci          })
756e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
757e41f4b71Sopenharmony_ci          .horizontalScrollBarAccess(this.isShow)
758e41f4b71Sopenharmony_ci      }
759e41f4b71Sopenharmony_ci    }
760e41f4b71Sopenharmony_ci  }
761e41f4b71Sopenharmony_ci  ```
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci  HTML file to be loaded:
764e41f4b71Sopenharmony_ci  ```html
765e41f4b71Sopenharmony_ci  <!--index.html-->
766e41f4b71Sopenharmony_ci  <!DOCTYPE html>
767e41f4b71Sopenharmony_ci  <html>
768e41f4b71Sopenharmony_ci  <head>
769e41f4b71Sopenharmony_ci      <title>Demo</title>
770e41f4b71Sopenharmony_ci      <style>
771e41f4b71Sopenharmony_ci        body {
772e41f4b71Sopenharmony_ci          width:3000px;
773e41f4b71Sopenharmony_ci          height:3000px;
774e41f4b71Sopenharmony_ci          padding-right:170px;
775e41f4b71Sopenharmony_ci          padding-left:170px;
776e41f4b71Sopenharmony_ci          border:5px solid blueviolet
777e41f4b71Sopenharmony_ci        }
778e41f4b71Sopenharmony_ci      </style>
779e41f4b71Sopenharmony_ci  </head>
780e41f4b71Sopenharmony_ci  <body>
781e41f4b71Sopenharmony_ci  Scroll Test
782e41f4b71Sopenharmony_ci  </body>
783e41f4b71Sopenharmony_ci  </html>
784e41f4b71Sopenharmony_ci  ```
785e41f4b71Sopenharmony_ci
786e41f4b71Sopenharmony_ci### verticalScrollBarAccess<sup>9+</sup>
787e41f4b71Sopenharmony_ci
788e41f4b71Sopenharmony_civerticalScrollBarAccess(verticalScrollBar: boolean)
789e41f4b71Sopenharmony_ci
790e41f4b71Sopenharmony_ciSets whether to display the vertical scrollbar, including the default system scrollbar and custom scrollbar. By default, the vertical scrollbar is displayed.
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci> **NOTE**
793e41f4b71Sopenharmony_ci>
794e41f4b71Sopenharmony_ci> - If an @State decorated variable is used to control the vertical scrollbar visibility, **controller.refresh()** must be called for the settings to take effect.
795e41f4b71Sopenharmony_ci> - If the vertical scrollbar visibility changes frequently through an @State decorated variable, it is recommended that the variable correspond to the **Web** component one by one.
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ci**Parameters**
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ci| Name              | Type   | Mandatory  | Default Value | Description        |
800e41f4b71Sopenharmony_ci| ----------------- | ------- | ---- | ---- | ------------ |
801e41f4b71Sopenharmony_ci| verticalScrollBar | boolean | Yes   | true | Whether to display the vertical scrollbar.|
802e41f4b71Sopenharmony_ci
803e41f4b71Sopenharmony_ci**Example**
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci  ```ts
806e41f4b71Sopenharmony_ci  // xxx.ets
807e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
808e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
809e41f4b71Sopenharmony_ci
810e41f4b71Sopenharmony_ci  @Entry
811e41f4b71Sopenharmony_ci  @Component
812e41f4b71Sopenharmony_ci  struct WebComponent {
813e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
814e41f4b71Sopenharmony_ci    @State isShow: boolean = false;
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci    build() {
817e41f4b71Sopenharmony_ci      Column() {
818e41f4b71Sopenharmony_ci        // If an @State decorated variable is used to control the vertical scrollbar visibility, controller.refresh() must be called for the settings to take effect.
819e41f4b71Sopenharmony_ci        Button('refresh')
820e41f4b71Sopenharmony_ci        .onClick(() => {
821e41f4b71Sopenharmony_ci          this.isShow = true;
822e41f4b71Sopenharmony_ci          try {
823e41f4b71Sopenharmony_ci            this.controller.refresh();
824e41f4b71Sopenharmony_ci          } catch (error) {
825e41f4b71Sopenharmony_ci            console.error(`ErrorCode: ${(error as BusinessError).code},  Message: ${(error as BusinessError).message}`);
826e41f4b71Sopenharmony_ci          }
827e41f4b71Sopenharmony_ci        })
828e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
829e41f4b71Sopenharmony_ci        .verticalScrollBarAccess(this.isShow)
830e41f4b71Sopenharmony_ci      }
831e41f4b71Sopenharmony_ci    }
832e41f4b71Sopenharmony_ci  }
833e41f4b71Sopenharmony_ci  ```
834e41f4b71Sopenharmony_ci
835e41f4b71Sopenharmony_ci  HTML file to be loaded:
836e41f4b71Sopenharmony_ci  ```html
837e41f4b71Sopenharmony_ci  <!--index.html-->
838e41f4b71Sopenharmony_ci  <!DOCTYPE html>
839e41f4b71Sopenharmony_ci  <html>
840e41f4b71Sopenharmony_ci  <head>
841e41f4b71Sopenharmony_ci      <title>Demo</title>
842e41f4b71Sopenharmony_ci      <style>
843e41f4b71Sopenharmony_ci        body {
844e41f4b71Sopenharmony_ci          width:3000px;
845e41f4b71Sopenharmony_ci          height:3000px;
846e41f4b71Sopenharmony_ci          padding-right:170px;
847e41f4b71Sopenharmony_ci          padding-left:170px;
848e41f4b71Sopenharmony_ci          border:5px solid blueviolet
849e41f4b71Sopenharmony_ci        }
850e41f4b71Sopenharmony_ci      </style>
851e41f4b71Sopenharmony_ci  </head>
852e41f4b71Sopenharmony_ci  <body>
853e41f4b71Sopenharmony_ci  Scroll Test
854e41f4b71Sopenharmony_ci  </body>
855e41f4b71Sopenharmony_ci  </html>
856e41f4b71Sopenharmony_ci  ```
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci### password<sup>(deprecated)</sup>
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_cipassword(password: boolean)
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ciSets whether the password should be saved. This API is a void API.
863e41f4b71Sopenharmony_ci
864e41f4b71Sopenharmony_ci> **NOTE**
865e41f4b71Sopenharmony_ci>
866e41f4b71Sopenharmony_ci> This API is deprecated since API version 10, and no new API is provided as a substitute.
867e41f4b71Sopenharmony_ci
868e41f4b71Sopenharmony_ci### cacheMode
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_cicacheMode(cacheMode: CacheMode)
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ciSets the cache mode.
873e41f4b71Sopenharmony_ci
874e41f4b71Sopenharmony_ci**Parameters**
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci| Name      | Type                       | Mandatory  | Default Value              | Description     |
877e41f4b71Sopenharmony_ci| --------- | --------------------------- | ---- | ----------------- | --------- |
878e41f4b71Sopenharmony_ci| cacheMode | [CacheMode](#cachemode9) | Yes   | CacheMode.Default | Cache mode to set.|
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ci**Example**
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci  ```ts
883e41f4b71Sopenharmony_ci  // xxx.ets
884e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci  @Entry
887e41f4b71Sopenharmony_ci  @Component
888e41f4b71Sopenharmony_ci  struct WebComponent {
889e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
890e41f4b71Sopenharmony_ci    @State mode: CacheMode = CacheMode.None;
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ci    build() {
893e41f4b71Sopenharmony_ci      Column() {
894e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
895e41f4b71Sopenharmony_ci          .cacheMode(this.mode)
896e41f4b71Sopenharmony_ci      }
897e41f4b71Sopenharmony_ci    }
898e41f4b71Sopenharmony_ci  }
899e41f4b71Sopenharmony_ci  ```
900e41f4b71Sopenharmony_ci
901e41f4b71Sopenharmony_ci### copyOptions<sup>11+</sup>
902e41f4b71Sopenharmony_ci
903e41f4b71Sopenharmony_cicopyOptions(value: CopyOptions)
904e41f4b71Sopenharmony_ci
905e41f4b71Sopenharmony_ciSets the pasteboard copy options.
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci**Parameters**
908e41f4b71Sopenharmony_ci
909e41f4b71Sopenharmony_ci| Name      | Type                       | Mandatory  | Default Value              | Description     |
910e41f4b71Sopenharmony_ci| --------- | --------------------------- | ---- | ----------------- | --------- |
911e41f4b71Sopenharmony_ci| value | [CopyOptions](../apis-arkui/arkui-ts/ts-appendix-enums.md#copyoptions9) | Yes   | CopyOptions.LocalDevice | Pasteboard copy options.|
912e41f4b71Sopenharmony_ci
913e41f4b71Sopenharmony_ci**Example**
914e41f4b71Sopenharmony_ci
915e41f4b71Sopenharmony_ci  ```ts
916e41f4b71Sopenharmony_ciimport { webview } from '@kit.ArkWeb';
917e41f4b71Sopenharmony_ci
918e41f4b71Sopenharmony_ci@Entry
919e41f4b71Sopenharmony_ci@Component
920e41f4b71Sopenharmony_cistruct WebComponent {
921e41f4b71Sopenharmony_ci  controller: webview.WebviewController = new webview.WebviewController();
922e41f4b71Sopenharmony_ci
923e41f4b71Sopenharmony_ci  build() {
924e41f4b71Sopenharmony_ci    Column() {
925e41f4b71Sopenharmony_ci      Web({ src: 'www.example.com', controller: this.controller })
926e41f4b71Sopenharmony_ci        .copyOptions(CopyOptions.None)
927e41f4b71Sopenharmony_ci    }
928e41f4b71Sopenharmony_ci  }
929e41f4b71Sopenharmony_ci}
930e41f4b71Sopenharmony_ci  ```
931e41f4b71Sopenharmony_ci
932e41f4b71Sopenharmony_ci### textZoomAtio<sup>(deprecated)</sup>
933e41f4b71Sopenharmony_ci
934e41f4b71Sopenharmony_citextZoomAtio(textZoomAtio: number)
935e41f4b71Sopenharmony_ci
936e41f4b71Sopenharmony_ciSets the text zoom ratio of the page. The default value is **100**, which indicates 100%.
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [textZoomRatio<sup>9+</sup>](#textzoomratio9) instead.
939e41f4b71Sopenharmony_ci
940e41f4b71Sopenharmony_ci**Parameters**
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_ci| Name         | Type  | Mandatory  | Default Value | Description                            |
943e41f4b71Sopenharmony_ci| ------------ | ------ | ---- | ---- | -------------------------------- |
944e41f4b71Sopenharmony_ci| textZoomAtio | number | Yes   | 100  | Text zoom ratio to set. The value is an integer. The value range is (0, +∞).|
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ci**Example**
947e41f4b71Sopenharmony_ci
948e41f4b71Sopenharmony_ci  ```ts
949e41f4b71Sopenharmony_ci  // xxx.ets
950e41f4b71Sopenharmony_ci  @Entry
951e41f4b71Sopenharmony_ci  @Component
952e41f4b71Sopenharmony_ci  struct WebComponent {
953e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
954e41f4b71Sopenharmony_ci    @State atio: number = 150
955e41f4b71Sopenharmony_ci    build() {
956e41f4b71Sopenharmony_ci      Column() {
957e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
958e41f4b71Sopenharmony_ci          .textZoomAtio(this.atio)
959e41f4b71Sopenharmony_ci      }
960e41f4b71Sopenharmony_ci    }
961e41f4b71Sopenharmony_ci  }
962e41f4b71Sopenharmony_ci  ```
963e41f4b71Sopenharmony_ci
964e41f4b71Sopenharmony_ci### textZoomRatio<sup>9+</sup>
965e41f4b71Sopenharmony_ci
966e41f4b71Sopenharmony_citextZoomRatio(textZoomRatio: number)
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ciSets the text zoom ratio of the page. The default value is **100**, which indicates 100%.
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_ci**Parameters**
971e41f4b71Sopenharmony_ci
972e41f4b71Sopenharmony_ci| Name          | Type  | Mandatory  | Default Value | Description                            |
973e41f4b71Sopenharmony_ci| ------------- | ------ | ---- | ---- | -------------------------------- |
974e41f4b71Sopenharmony_ci| textZoomRatio | number | Yes   | 100  | Text zoom ratio to set. The value is an integer. The value range is (0, +∞).|
975e41f4b71Sopenharmony_ci
976e41f4b71Sopenharmony_ci**Example**
977e41f4b71Sopenharmony_ci
978e41f4b71Sopenharmony_ci  ```ts
979e41f4b71Sopenharmony_ci  // xxx.ets
980e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
981e41f4b71Sopenharmony_ci
982e41f4b71Sopenharmony_ci  @Entry
983e41f4b71Sopenharmony_ci  @Component
984e41f4b71Sopenharmony_ci  struct WebComponent {
985e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
986e41f4b71Sopenharmony_ci    @State atio: number = 150;
987e41f4b71Sopenharmony_ci
988e41f4b71Sopenharmony_ci    build() {
989e41f4b71Sopenharmony_ci      Column() {
990e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
991e41f4b71Sopenharmony_ci          .textZoomRatio(this.atio)
992e41f4b71Sopenharmony_ci      }
993e41f4b71Sopenharmony_ci    }
994e41f4b71Sopenharmony_ci  }
995e41f4b71Sopenharmony_ci  ```
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_ci### initialScale<sup>9+</sup>
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ciinitialScale(percent: number)
1000e41f4b71Sopenharmony_ci
1001e41f4b71Sopenharmony_ciSets the scale factor of the entire page. The default value is 100%.
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci**Parameters**
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory  | Default Value | Description                         |
1006e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ---- | ----------------------------- |
1007e41f4b71Sopenharmony_ci| percent | number | Yes   | 100  | Scale factor of the entire page.|
1008e41f4b71Sopenharmony_ci
1009e41f4b71Sopenharmony_ci**Example**
1010e41f4b71Sopenharmony_ci
1011e41f4b71Sopenharmony_ci  ```ts
1012e41f4b71Sopenharmony_ci  // xxx.ets
1013e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1014e41f4b71Sopenharmony_ci
1015e41f4b71Sopenharmony_ci  @Entry
1016e41f4b71Sopenharmony_ci  @Component
1017e41f4b71Sopenharmony_ci  struct WebComponent {
1018e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1019e41f4b71Sopenharmony_ci    @State percent: number = 100;
1020e41f4b71Sopenharmony_ci
1021e41f4b71Sopenharmony_ci    build() {
1022e41f4b71Sopenharmony_ci      Column() {
1023e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1024e41f4b71Sopenharmony_ci          .initialScale(this.percent)
1025e41f4b71Sopenharmony_ci      }
1026e41f4b71Sopenharmony_ci    }
1027e41f4b71Sopenharmony_ci  }
1028e41f4b71Sopenharmony_ci  ```
1029e41f4b71Sopenharmony_ci
1030e41f4b71Sopenharmony_ci### userAgent<sup>(deprecated)</sup>
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_ciuserAgent(userAgent: string)
1033e41f4b71Sopenharmony_ci
1034e41f4b71Sopenharmony_ciSets the user agent.
1035e41f4b71Sopenharmony_ci
1036e41f4b71Sopenharmony_ci> **NOTE**
1037e41f4b71Sopenharmony_ci>
1038e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 10. You are advised to use [setCustomUserAgent](js-apis-webview.md#setcustomuseragent10)<sup>10+</sup> instead.
1039e41f4b71Sopenharmony_ci
1040e41f4b71Sopenharmony_ci**Parameters**
1041e41f4b71Sopenharmony_ci
1042e41f4b71Sopenharmony_ci| Name      | Type  | Mandatory  | Default Value | Description     |
1043e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ---- | --------- |
1044e41f4b71Sopenharmony_ci| userAgent | string | Yes   | -    | User agent to set.|
1045e41f4b71Sopenharmony_ci
1046e41f4b71Sopenharmony_ci**Example**
1047e41f4b71Sopenharmony_ci
1048e41f4b71Sopenharmony_ci  ```ts
1049e41f4b71Sopenharmony_ci  // xxx.ets
1050e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1051e41f4b71Sopenharmony_ci
1052e41f4b71Sopenharmony_ci  @Entry
1053e41f4b71Sopenharmony_ci  @Component
1054e41f4b71Sopenharmony_ci  struct WebComponent {
1055e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1056e41f4b71Sopenharmony_ci    @State userAgent:string = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36';
1057e41f4b71Sopenharmony_ci
1058e41f4b71Sopenharmony_ci    build() {
1059e41f4b71Sopenharmony_ci      Column() {
1060e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1061e41f4b71Sopenharmony_ci          .userAgent(this.userAgent)
1062e41f4b71Sopenharmony_ci      }
1063e41f4b71Sopenharmony_ci    }
1064e41f4b71Sopenharmony_ci  }
1065e41f4b71Sopenharmony_ci  ```
1066e41f4b71Sopenharmony_ci
1067e41f4b71Sopenharmony_ci### blockNetwork<sup>9+</sup>
1068e41f4b71Sopenharmony_ci
1069e41f4b71Sopenharmony_ciblockNetwork(block: boolean)
1070e41f4b71Sopenharmony_ci
1071e41f4b71Sopenharmony_ciSets whether to block online downloads.
1072e41f4b71Sopenharmony_ci
1073e41f4b71Sopenharmony_ci**Parameters**
1074e41f4b71Sopenharmony_ci
1075e41f4b71Sopenharmony_ci| Name  | Type   | Mandatory  | Default Value  | Description               |
1076e41f4b71Sopenharmony_ci| ----- | ------- | ---- | ----- | ------------------- |
1077e41f4b71Sopenharmony_ci| block | boolean | Yes   | false | Whether to block online downloads.|
1078e41f4b71Sopenharmony_ci
1079e41f4b71Sopenharmony_ci**Example**
1080e41f4b71Sopenharmony_ci
1081e41f4b71Sopenharmony_ci  ```ts
1082e41f4b71Sopenharmony_ci  // xxx.ets
1083e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1084e41f4b71Sopenharmony_ci
1085e41f4b71Sopenharmony_ci  @Entry
1086e41f4b71Sopenharmony_ci  @Component
1087e41f4b71Sopenharmony_ci  struct WebComponent {
1088e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1089e41f4b71Sopenharmony_ci    @State block: boolean = true;
1090e41f4b71Sopenharmony_ci
1091e41f4b71Sopenharmony_ci    build() {
1092e41f4b71Sopenharmony_ci      Column() {
1093e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1094e41f4b71Sopenharmony_ci          .blockNetwork(this.block)
1095e41f4b71Sopenharmony_ci      }
1096e41f4b71Sopenharmony_ci    }
1097e41f4b71Sopenharmony_ci  }
1098e41f4b71Sopenharmony_ci  ```
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_ci### defaultFixedFontSize<sup>9+</sup>
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_cidefaultFixedFontSize(size: number)
1103e41f4b71Sopenharmony_ci
1104e41f4b71Sopenharmony_ciSets the default fixed font size for the web page.
1105e41f4b71Sopenharmony_ci
1106e41f4b71Sopenharmony_ci**Parameters**
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description                                    |
1109e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ---------------------------------------- |
1110e41f4b71Sopenharmony_ci| size | number | Yes   | 13   | Default fixed font size to set, in px. The value ranges from -2^31 to 2^31-1. In actual rendering, values greater than 72 are handled as 72, and values less than 1 are handled as 1.|
1111e41f4b71Sopenharmony_ci
1112e41f4b71Sopenharmony_ci**Example**
1113e41f4b71Sopenharmony_ci
1114e41f4b71Sopenharmony_ci  ```ts
1115e41f4b71Sopenharmony_ci  // xxx.ets
1116e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1117e41f4b71Sopenharmony_ci
1118e41f4b71Sopenharmony_ci  @Entry
1119e41f4b71Sopenharmony_ci  @Component
1120e41f4b71Sopenharmony_ci  struct WebComponent {
1121e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1122e41f4b71Sopenharmony_ci    @State fontSize: number = 16;
1123e41f4b71Sopenharmony_ci
1124e41f4b71Sopenharmony_ci    build() {
1125e41f4b71Sopenharmony_ci      Column() {
1126e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1127e41f4b71Sopenharmony_ci          .defaultFixedFontSize(this.fontSize)
1128e41f4b71Sopenharmony_ci      }
1129e41f4b71Sopenharmony_ci    }
1130e41f4b71Sopenharmony_ci  }
1131e41f4b71Sopenharmony_ci  ```
1132e41f4b71Sopenharmony_ci
1133e41f4b71Sopenharmony_ci### defaultFontSize<sup>9+</sup>
1134e41f4b71Sopenharmony_ci
1135e41f4b71Sopenharmony_cidefaultFontSize(size: number)
1136e41f4b71Sopenharmony_ci
1137e41f4b71Sopenharmony_ciSets the default font size for the web page.
1138e41f4b71Sopenharmony_ci
1139e41f4b71Sopenharmony_ci**Parameters**
1140e41f4b71Sopenharmony_ci
1141e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description                                    |
1142e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ---------------------------------------- |
1143e41f4b71Sopenharmony_ci| size | number | Yes   | 16   | Default font size to set, in px. The value ranges from -2^31 to 2^31-1. In actual rendering, values greater than 72 are handled as 72, and values less than 1 are handled as 1.|
1144e41f4b71Sopenharmony_ci
1145e41f4b71Sopenharmony_ci**Example**
1146e41f4b71Sopenharmony_ci
1147e41f4b71Sopenharmony_ci  ```ts
1148e41f4b71Sopenharmony_ci  // xxx.ets
1149e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1150e41f4b71Sopenharmony_ci
1151e41f4b71Sopenharmony_ci  @Entry
1152e41f4b71Sopenharmony_ci  @Component
1153e41f4b71Sopenharmony_ci  struct WebComponent {
1154e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1155e41f4b71Sopenharmony_ci    @State fontSize: number = 13;
1156e41f4b71Sopenharmony_ci
1157e41f4b71Sopenharmony_ci    build() {
1158e41f4b71Sopenharmony_ci      Column() {
1159e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1160e41f4b71Sopenharmony_ci          .defaultFontSize(this.fontSize)
1161e41f4b71Sopenharmony_ci      }
1162e41f4b71Sopenharmony_ci    }
1163e41f4b71Sopenharmony_ci  }
1164e41f4b71Sopenharmony_ci  ```
1165e41f4b71Sopenharmony_ci
1166e41f4b71Sopenharmony_ci### minFontSize<sup>9+</sup>
1167e41f4b71Sopenharmony_ci
1168e41f4b71Sopenharmony_ciminFontSize(size: number)
1169e41f4b71Sopenharmony_ci
1170e41f4b71Sopenharmony_ciSets the minimum font size for the web page.
1171e41f4b71Sopenharmony_ci
1172e41f4b71Sopenharmony_ci**Parameters**
1173e41f4b71Sopenharmony_ci
1174e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description                                    |
1175e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ---------------------------------------- |
1176e41f4b71Sopenharmony_ci| size | number | Yes   | 8    | Minimum font size to set, in px. The value ranges from -2^31 to 2^31-1. In actual rendering, values greater than 72 are handled as 72, and values less than 1 are handled as 1.|
1177e41f4b71Sopenharmony_ci
1178e41f4b71Sopenharmony_ci**Example**
1179e41f4b71Sopenharmony_ci
1180e41f4b71Sopenharmony_ci  ```ts
1181e41f4b71Sopenharmony_ci  // xxx.ets
1182e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1183e41f4b71Sopenharmony_ci
1184e41f4b71Sopenharmony_ci  @Entry
1185e41f4b71Sopenharmony_ci  @Component
1186e41f4b71Sopenharmony_ci  struct WebComponent {
1187e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1188e41f4b71Sopenharmony_ci    @State fontSize: number = 13;
1189e41f4b71Sopenharmony_ci
1190e41f4b71Sopenharmony_ci    build() {
1191e41f4b71Sopenharmony_ci      Column() {
1192e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1193e41f4b71Sopenharmony_ci          .minFontSize(this.fontSize)
1194e41f4b71Sopenharmony_ci      }
1195e41f4b71Sopenharmony_ci    }
1196e41f4b71Sopenharmony_ci  }
1197e41f4b71Sopenharmony_ci  ```
1198e41f4b71Sopenharmony_ci
1199e41f4b71Sopenharmony_ci### minLogicalFontSize<sup>9+</sup>
1200e41f4b71Sopenharmony_ci
1201e41f4b71Sopenharmony_ciminLogicalFontSize(size: number)
1202e41f4b71Sopenharmony_ci
1203e41f4b71Sopenharmony_ciSets the minimum logical font size for the web page.
1204e41f4b71Sopenharmony_ci
1205e41f4b71Sopenharmony_ci**Parameters**
1206e41f4b71Sopenharmony_ci
1207e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description                                    |
1208e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ---------------------------------------- |
1209e41f4b71Sopenharmony_ci| size | number | Yes   | 8    | Minimum logical font size to set, in px. The value ranges from -2^31 to 2^31-1. In actual rendering, values greater than 72 are handled as 72, and values less than 1 are handled as 1.|
1210e41f4b71Sopenharmony_ci
1211e41f4b71Sopenharmony_ci**Example**
1212e41f4b71Sopenharmony_ci
1213e41f4b71Sopenharmony_ci  ```ts
1214e41f4b71Sopenharmony_ci  // xxx.ets
1215e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1216e41f4b71Sopenharmony_ci
1217e41f4b71Sopenharmony_ci  @Entry
1218e41f4b71Sopenharmony_ci  @Component
1219e41f4b71Sopenharmony_ci  struct WebComponent {
1220e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1221e41f4b71Sopenharmony_ci    @State fontSize: number = 13;
1222e41f4b71Sopenharmony_ci
1223e41f4b71Sopenharmony_ci    build() {
1224e41f4b71Sopenharmony_ci      Column() {
1225e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1226e41f4b71Sopenharmony_ci          .minLogicalFontSize(this.fontSize)
1227e41f4b71Sopenharmony_ci      }
1228e41f4b71Sopenharmony_ci    }
1229e41f4b71Sopenharmony_ci  }
1230e41f4b71Sopenharmony_ci  ```
1231e41f4b71Sopenharmony_ci
1232e41f4b71Sopenharmony_ci### webFixedFont<sup>9+</sup>
1233e41f4b71Sopenharmony_ci
1234e41f4b71Sopenharmony_ciwebFixedFont(family: string)
1235e41f4b71Sopenharmony_ci
1236e41f4b71Sopenharmony_ciSets the fixed font family for the web page.
1237e41f4b71Sopenharmony_ci
1238e41f4b71Sopenharmony_ci**Parameters**
1239e41f4b71Sopenharmony_ci
1240e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Default Value      | Description               |
1241e41f4b71Sopenharmony_ci| ------ | ------ | ---- | --------- | ------------------- |
1242e41f4b71Sopenharmony_ci| family | string | Yes   | monospace | Fixed font family to set.|
1243e41f4b71Sopenharmony_ci
1244e41f4b71Sopenharmony_ci**Example**
1245e41f4b71Sopenharmony_ci
1246e41f4b71Sopenharmony_ci  ```ts
1247e41f4b71Sopenharmony_ci  // xxx.ets
1248e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ci  @Entry
1251e41f4b71Sopenharmony_ci  @Component
1252e41f4b71Sopenharmony_ci  struct WebComponent {
1253e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1254e41f4b71Sopenharmony_ci    @State family: string = "monospace";
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ci    build() {
1257e41f4b71Sopenharmony_ci      Column() {
1258e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1259e41f4b71Sopenharmony_ci          .webFixedFont(this.family)
1260e41f4b71Sopenharmony_ci      }
1261e41f4b71Sopenharmony_ci    }
1262e41f4b71Sopenharmony_ci  }
1263e41f4b71Sopenharmony_ci  ```
1264e41f4b71Sopenharmony_ci
1265e41f4b71Sopenharmony_ci### webSansSerifFont<sup>9+</sup>
1266e41f4b71Sopenharmony_ci
1267e41f4b71Sopenharmony_ciwebSansSerifFont(family: string)
1268e41f4b71Sopenharmony_ci
1269e41f4b71Sopenharmony_ciSets the sans serif font family for the web page.
1270e41f4b71Sopenharmony_ci
1271e41f4b71Sopenharmony_ci**Parameters**
1272e41f4b71Sopenharmony_ci
1273e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Default Value       | Description                    |
1274e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------- | ------------------------ |
1275e41f4b71Sopenharmony_ci| family | string | Yes   | sans-serif | Sans serif font family to set.|
1276e41f4b71Sopenharmony_ci
1277e41f4b71Sopenharmony_ci**Example**
1278e41f4b71Sopenharmony_ci
1279e41f4b71Sopenharmony_ci  ```ts
1280e41f4b71Sopenharmony_ci  // xxx.ets
1281e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1282e41f4b71Sopenharmony_ci
1283e41f4b71Sopenharmony_ci  @Entry
1284e41f4b71Sopenharmony_ci  @Component
1285e41f4b71Sopenharmony_ci  struct WebComponent {
1286e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1287e41f4b71Sopenharmony_ci    @State family: string = "sans-serif";
1288e41f4b71Sopenharmony_ci
1289e41f4b71Sopenharmony_ci    build() {
1290e41f4b71Sopenharmony_ci      Column() {
1291e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1292e41f4b71Sopenharmony_ci          .webSansSerifFont(this.family)
1293e41f4b71Sopenharmony_ci      }
1294e41f4b71Sopenharmony_ci    }
1295e41f4b71Sopenharmony_ci  }
1296e41f4b71Sopenharmony_ci  ```
1297e41f4b71Sopenharmony_ci
1298e41f4b71Sopenharmony_ci### webSerifFont<sup>9+</sup>
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ciwebSerifFont(family: string)
1301e41f4b71Sopenharmony_ci
1302e41f4b71Sopenharmony_ciSets the serif font family for the web page.
1303e41f4b71Sopenharmony_ci
1304e41f4b71Sopenharmony_ci**Parameters**
1305e41f4b71Sopenharmony_ci
1306e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Default Value  | Description               |
1307e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ----- | ------------------- |
1308e41f4b71Sopenharmony_ci| family | string | Yes   | serif | Serif font family to set.|
1309e41f4b71Sopenharmony_ci
1310e41f4b71Sopenharmony_ci**Example**
1311e41f4b71Sopenharmony_ci
1312e41f4b71Sopenharmony_ci  ```ts
1313e41f4b71Sopenharmony_ci  // xxx.ets
1314e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci  @Entry
1317e41f4b71Sopenharmony_ci  @Component
1318e41f4b71Sopenharmony_ci  struct WebComponent {
1319e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1320e41f4b71Sopenharmony_ci    @State family: string = "serif";
1321e41f4b71Sopenharmony_ci
1322e41f4b71Sopenharmony_ci    build() {
1323e41f4b71Sopenharmony_ci      Column() {
1324e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1325e41f4b71Sopenharmony_ci          .webSerifFont(this.family)
1326e41f4b71Sopenharmony_ci      }
1327e41f4b71Sopenharmony_ci    }
1328e41f4b71Sopenharmony_ci  }
1329e41f4b71Sopenharmony_ci  ```
1330e41f4b71Sopenharmony_ci
1331e41f4b71Sopenharmony_ci### webStandardFont<sup>9+</sup>
1332e41f4b71Sopenharmony_ci
1333e41f4b71Sopenharmony_ciwebStandardFont(family: string)
1334e41f4b71Sopenharmony_ci
1335e41f4b71Sopenharmony_ciSets the standard font family for the web page.
1336e41f4b71Sopenharmony_ci
1337e41f4b71Sopenharmony_ci**Parameters**
1338e41f4b71Sopenharmony_ci
1339e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Default Value       | Description                  |
1340e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------- | ---------------------- |
1341e41f4b71Sopenharmony_ci| family | string | Yes   | sans serif | Standard font family to set.|
1342e41f4b71Sopenharmony_ci
1343e41f4b71Sopenharmony_ci**Example**
1344e41f4b71Sopenharmony_ci
1345e41f4b71Sopenharmony_ci  ```ts
1346e41f4b71Sopenharmony_ci  // xxx.ets
1347e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1348e41f4b71Sopenharmony_ci
1349e41f4b71Sopenharmony_ci  @Entry
1350e41f4b71Sopenharmony_ci  @Component
1351e41f4b71Sopenharmony_ci  struct WebComponent {
1352e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1353e41f4b71Sopenharmony_ci    @State family: string = "sans-serif";
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_ci    build() {
1356e41f4b71Sopenharmony_ci      Column() {
1357e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1358e41f4b71Sopenharmony_ci          .webStandardFont(this.family)
1359e41f4b71Sopenharmony_ci      }
1360e41f4b71Sopenharmony_ci    }
1361e41f4b71Sopenharmony_ci  }
1362e41f4b71Sopenharmony_ci  ```
1363e41f4b71Sopenharmony_ci
1364e41f4b71Sopenharmony_ci### webFantasyFont<sup>9+</sup>
1365e41f4b71Sopenharmony_ci
1366e41f4b71Sopenharmony_ciwebFantasyFont(family: string)
1367e41f4b71Sopenharmony_ci
1368e41f4b71Sopenharmony_ciSets the fantasy font family for the web page.
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_ci**Parameters**
1371e41f4b71Sopenharmony_ci
1372e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Default Value    | Description                 |
1373e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | --------------------- |
1374e41f4b71Sopenharmony_ci| family | string | Yes   | fantasy | Fantasy font family to set.|
1375e41f4b71Sopenharmony_ci
1376e41f4b71Sopenharmony_ci**Example**
1377e41f4b71Sopenharmony_ci
1378e41f4b71Sopenharmony_ci  ```ts
1379e41f4b71Sopenharmony_ci  // xxx.ets
1380e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1381e41f4b71Sopenharmony_ci  @Entry
1382e41f4b71Sopenharmony_ci  @Component
1383e41f4b71Sopenharmony_ci  struct WebComponent {
1384e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1385e41f4b71Sopenharmony_ci    @State family: string = "fantasy";
1386e41f4b71Sopenharmony_ci
1387e41f4b71Sopenharmony_ci    build() {
1388e41f4b71Sopenharmony_ci      Column() {
1389e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1390e41f4b71Sopenharmony_ci          .webFantasyFont(this.family)
1391e41f4b71Sopenharmony_ci      }
1392e41f4b71Sopenharmony_ci    }
1393e41f4b71Sopenharmony_ci  }
1394e41f4b71Sopenharmony_ci  ```
1395e41f4b71Sopenharmony_ci
1396e41f4b71Sopenharmony_ci### webCursiveFont<sup>9+</sup>
1397e41f4b71Sopenharmony_ci
1398e41f4b71Sopenharmony_ciwebCursiveFont(family: string)
1399e41f4b71Sopenharmony_ci
1400e41f4b71Sopenharmony_ciSets the cursive font family for the web page.
1401e41f4b71Sopenharmony_ci
1402e41f4b71Sopenharmony_ci**Parameters**
1403e41f4b71Sopenharmony_ci
1404e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Default Value    | Description                 |
1405e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------- | --------------------- |
1406e41f4b71Sopenharmony_ci| family | string | Yes   | cursive | Cursive font family to set.|
1407e41f4b71Sopenharmony_ci
1408e41f4b71Sopenharmony_ci**Example**
1409e41f4b71Sopenharmony_ci
1410e41f4b71Sopenharmony_ci  ```ts
1411e41f4b71Sopenharmony_ci  // xxx.ets
1412e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1413e41f4b71Sopenharmony_ci
1414e41f4b71Sopenharmony_ci  @Entry
1415e41f4b71Sopenharmony_ci  @Component
1416e41f4b71Sopenharmony_ci  struct WebComponent {
1417e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1418e41f4b71Sopenharmony_ci    @State family: string = "cursive";
1419e41f4b71Sopenharmony_ci
1420e41f4b71Sopenharmony_ci    build() {
1421e41f4b71Sopenharmony_ci      Column() {
1422e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1423e41f4b71Sopenharmony_ci          .webCursiveFont(this.family)
1424e41f4b71Sopenharmony_ci      }
1425e41f4b71Sopenharmony_ci    }
1426e41f4b71Sopenharmony_ci  }
1427e41f4b71Sopenharmony_ci  ```
1428e41f4b71Sopenharmony_ci
1429e41f4b71Sopenharmony_ci### darkMode<sup>9+</sup>
1430e41f4b71Sopenharmony_ci
1431e41f4b71Sopenharmony_cidarkMode(mode: WebDarkMode)
1432e41f4b71Sopenharmony_ci
1433e41f4b71Sopenharmony_ciSets the web dark mode. By default, web dark mode is disabled. When it is enabled, the **Web** component enables the dark theme defined for web pages if the theme has been defined in **prefers-color-scheme** of a media query, and remains unchanged otherwise. To enable the forcible dark mode, use this API with [forceDarkAccess](#forcedarkaccess9).
1434e41f4b71Sopenharmony_ci
1435e41f4b71Sopenharmony_ci**Parameters**
1436e41f4b71Sopenharmony_ci
1437e41f4b71Sopenharmony_ci| Name | Type                            | Mandatory  | Default Value            | Description                  |
1438e41f4b71Sopenharmony_ci| ---- | -------------------------------- | ---- | --------------- | ---------------------- |
1439e41f4b71Sopenharmony_ci| mode | [WebDarkMode](#webdarkmode9) | Yes   | WebDarkMode.Off | Web dark mode to set.|
1440e41f4b71Sopenharmony_ci
1441e41f4b71Sopenharmony_ci**Example**
1442e41f4b71Sopenharmony_ci
1443e41f4b71Sopenharmony_ci  ```ts
1444e41f4b71Sopenharmony_ci  // xxx.ets
1445e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1446e41f4b71Sopenharmony_ci
1447e41f4b71Sopenharmony_ci  @Entry
1448e41f4b71Sopenharmony_ci  @Component
1449e41f4b71Sopenharmony_ci  struct WebComponent {
1450e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1451e41f4b71Sopenharmony_ci    @State mode: WebDarkMode = WebDarkMode.On;
1452e41f4b71Sopenharmony_ci
1453e41f4b71Sopenharmony_ci    build() {
1454e41f4b71Sopenharmony_ci      Column() {
1455e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1456e41f4b71Sopenharmony_ci          .darkMode(this.mode)
1457e41f4b71Sopenharmony_ci      }
1458e41f4b71Sopenharmony_ci    }
1459e41f4b71Sopenharmony_ci  }
1460e41f4b71Sopenharmony_ci  ```
1461e41f4b71Sopenharmony_ci
1462e41f4b71Sopenharmony_ci### forceDarkAccess<sup>9+</sup>
1463e41f4b71Sopenharmony_ci
1464e41f4b71Sopenharmony_ciforceDarkAccess(access: boolean)
1465e41f4b71Sopenharmony_ci
1466e41f4b71Sopenharmony_ciSets whether to enable forcible dark mode for the web page. By default, this feature is turned off. This API is applicable only when dark mode is enabled in [darkMode](#darkmode9).
1467e41f4b71Sopenharmony_ci
1468e41f4b71Sopenharmony_ci**Parameters**
1469e41f4b71Sopenharmony_ci
1470e41f4b71Sopenharmony_ci| Name   | Type   | Mandatory  | Default Value  | Description           |
1471e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ----- | --------------- |
1472e41f4b71Sopenharmony_ci| access | boolean | Yes   | false | Whether to enable forcible dark mode for the web page.|
1473e41f4b71Sopenharmony_ci
1474e41f4b71Sopenharmony_ci**Example**
1475e41f4b71Sopenharmony_ci
1476e41f4b71Sopenharmony_ci  ```ts
1477e41f4b71Sopenharmony_ci  // xxx.ets
1478e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1479e41f4b71Sopenharmony_ci
1480e41f4b71Sopenharmony_ci  @Entry
1481e41f4b71Sopenharmony_ci  @Component
1482e41f4b71Sopenharmony_ci  struct WebComponent {
1483e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1484e41f4b71Sopenharmony_ci    @State mode: WebDarkMode = WebDarkMode.On;
1485e41f4b71Sopenharmony_ci    @State access: boolean = true;
1486e41f4b71Sopenharmony_ci
1487e41f4b71Sopenharmony_ci    build() {
1488e41f4b71Sopenharmony_ci      Column() {
1489e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1490e41f4b71Sopenharmony_ci          .darkMode(this.mode)
1491e41f4b71Sopenharmony_ci          .forceDarkAccess(this.access)
1492e41f4b71Sopenharmony_ci      }
1493e41f4b71Sopenharmony_ci    }
1494e41f4b71Sopenharmony_ci  }
1495e41f4b71Sopenharmony_ci  ```
1496e41f4b71Sopenharmony_ci
1497e41f4b71Sopenharmony_ci### tableData<sup>(deprecated)</sup>
1498e41f4b71Sopenharmony_ci
1499e41f4b71Sopenharmony_citableData(tableData: boolean)
1500e41f4b71Sopenharmony_ci
1501e41f4b71Sopenharmony_ciSets whether form data should be saved. This API is a void API.
1502e41f4b71Sopenharmony_ci
1503e41f4b71Sopenharmony_ci> **NOTE**
1504e41f4b71Sopenharmony_ci>
1505e41f4b71Sopenharmony_ci> This API is deprecated since API version 10, and no new API is provided as a substitute.
1506e41f4b71Sopenharmony_ci
1507e41f4b71Sopenharmony_ci### wideViewModeAccess<sup>(deprecated)</sup>
1508e41f4b71Sopenharmony_ci
1509e41f4b71Sopenharmony_ciwideViewModeAccess(wideViewModeAccess: boolean)
1510e41f4b71Sopenharmony_ci
1511e41f4b71Sopenharmony_ciSets whether to support the viewport attribute of the HTML **\<meta>** tag. This API is a void API.
1512e41f4b71Sopenharmony_ci
1513e41f4b71Sopenharmony_ci> **NOTE**
1514e41f4b71Sopenharmony_ci>
1515e41f4b71Sopenharmony_ci> This API is deprecated since API version 10, and no new API is provided as a substitute.
1516e41f4b71Sopenharmony_ci
1517e41f4b71Sopenharmony_ci### pinchSmooth<sup>9+</sup>
1518e41f4b71Sopenharmony_ci
1519e41f4b71Sopenharmony_cipinchSmooth(isEnabled: boolean)
1520e41f4b71Sopenharmony_ci
1521e41f4b71Sopenharmony_ciSets whether to enable smooth pinch mode for the web page.
1522e41f4b71Sopenharmony_ci
1523e41f4b71Sopenharmony_ci**Parameters**
1524e41f4b71Sopenharmony_ci
1525e41f4b71Sopenharmony_ci| Name      | Type   | Mandatory  | Default Value  | Description         |
1526e41f4b71Sopenharmony_ci| --------- | ------- | ---- | ----- | ------------- |
1527e41f4b71Sopenharmony_ci| isEnabled | boolean | Yes   | false | Whether to enable smooth pinch mode for the web page.|
1528e41f4b71Sopenharmony_ci
1529e41f4b71Sopenharmony_ci**Example**
1530e41f4b71Sopenharmony_ci
1531e41f4b71Sopenharmony_ci  ```ts
1532e41f4b71Sopenharmony_ci  // xxx.ets
1533e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1534e41f4b71Sopenharmony_ci
1535e41f4b71Sopenharmony_ci  @Entry
1536e41f4b71Sopenharmony_ci  @Component
1537e41f4b71Sopenharmony_ci  struct WebComponent {
1538e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1539e41f4b71Sopenharmony_ci
1540e41f4b71Sopenharmony_ci    build() {
1541e41f4b71Sopenharmony_ci      Column() {
1542e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1543e41f4b71Sopenharmony_ci          .pinchSmooth(true)
1544e41f4b71Sopenharmony_ci      }
1545e41f4b71Sopenharmony_ci    }
1546e41f4b71Sopenharmony_ci  }
1547e41f4b71Sopenharmony_ci  ```
1548e41f4b71Sopenharmony_ci
1549e41f4b71Sopenharmony_ci### allowWindowOpenMethod<sup>10+</sup>
1550e41f4b71Sopenharmony_ci
1551e41f4b71Sopenharmony_ciallowWindowOpenMethod(flag: boolean)
1552e41f4b71Sopenharmony_ci
1553e41f4b71Sopenharmony_ciSets whether to allow a new window to automatically open through JavaScript.
1554e41f4b71Sopenharmony_ci
1555e41f4b71Sopenharmony_ciWhen **flag** is set to **true**, a new window can automatically open through JavaScript. When **flag** is set to **false**, a new window can still automatically open through JavaScript for user behavior, but cannot for non-user behavior. The user behavior here refers to that a user requests to open a new window (**window.open**) within 5 seconds of operating the **Web** component.
1556e41f4b71Sopenharmony_ci
1557e41f4b71Sopenharmony_ciThis API takes effect only when [javaScriptAccess](#javascriptaccess) is enabled.
1558e41f4b71Sopenharmony_ci
1559e41f4b71Sopenharmony_ciThis API opens a new window when [multiWindowAccess](#multiwindowaccess9) is enabled and opens a local window when [multiWindowAccess](#multiwindowaccess9) is disabled.
1560e41f4b71Sopenharmony_ci
1561e41f4b71Sopenharmony_ciThe default value of **flag** is subject to the settings of the **persist.web.allowWindowOpenMethod.enabled** system attribute. If this attribute is not set, the default value of **flag** is **false**.
1562e41f4b71Sopenharmony_ci
1563e41f4b71Sopenharmony_ciTo check the settings of **persist.web.allowWindowOpenMethod.enabled**,
1564e41f4b71Sopenharmony_ci
1565e41f4b71Sopenharmony_cirun the **hdc shell param get persist.web.allowWindowOpenMethod.enabled** command. If the attribute is set to 0 or does not exist,
1566e41f4b71Sopenharmony_ciyou can run the **hdc shell param set persist.web.allowWindowOpenMethod.enabled 1** command to enable it.
1567e41f4b71Sopenharmony_ci
1568e41f4b71Sopenharmony_ci**Parameters**
1569e41f4b71Sopenharmony_ci
1570e41f4b71Sopenharmony_ci| Name | Type   | Mandatory  | Default Value                                     | Description                     |
1571e41f4b71Sopenharmony_ci| ---- | ------- | ---- | ---------------------------------------- | ------------------------- |
1572e41f4b71Sopenharmony_ci| flag | boolean | Yes   | Subject to the settings of the **persist.web.allowWindowOpenMethod.enabled** system attribute. If this attribute is set, the default value of **flag** is **true**. Otherwise, the default value of **flag** is **false**.| Whether to allow a new window to automatically open through JavaScript.|
1573e41f4b71Sopenharmony_ci
1574e41f4b71Sopenharmony_ci**Example**
1575e41f4b71Sopenharmony_ci
1576e41f4b71Sopenharmony_ci  ```ts
1577e41f4b71Sopenharmony_ci  // xxx.ets
1578e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1579e41f4b71Sopenharmony_ci
1580e41f4b71Sopenharmony_ci  // There are two Web components on the same page. When the Web Component object opens a new window, the NewWebViewComp object is displayed. 
1581e41f4b71Sopenharmony_ci  @CustomDialog
1582e41f4b71Sopenharmony_ci  struct NewWebViewComp {
1583e41f4b71Sopenharmony_ci    controller?: CustomDialogController;
1584e41f4b71Sopenharmony_ci    webviewController1: webview.WebviewController = new webview.WebviewController();
1585e41f4b71Sopenharmony_ci
1586e41f4b71Sopenharmony_ci    build() {
1587e41f4b71Sopenharmony_ci      Column() {
1588e41f4b71Sopenharmony_ci        Web({ src: "", controller: this.webviewController1 })
1589e41f4b71Sopenharmony_ci          .javaScriptAccess(true)
1590e41f4b71Sopenharmony_ci          .multiWindowAccess(false)
1591e41f4b71Sopenharmony_ci          .onWindowExit(() => {
1592e41f4b71Sopenharmony_ci            console.info("NewWebViewComp onWindowExit");
1593e41f4b71Sopenharmony_ci            if (this.controller) {
1594e41f4b71Sopenharmony_ci              this.controller.close();
1595e41f4b71Sopenharmony_ci            }
1596e41f4b71Sopenharmony_ci          })
1597e41f4b71Sopenharmony_ci      }
1598e41f4b71Sopenharmony_ci    }
1599e41f4b71Sopenharmony_ci  }
1600e41f4b71Sopenharmony_ci
1601e41f4b71Sopenharmony_ci  @Entry
1602e41f4b71Sopenharmony_ci  @Component
1603e41f4b71Sopenharmony_ci  struct WebComponent {
1604e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1605e41f4b71Sopenharmony_ci    dialogController: CustomDialogController | null = null;
1606e41f4b71Sopenharmony_ci
1607e41f4b71Sopenharmony_ci    build() {
1608e41f4b71Sopenharmony_ci      Column() {
1609e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1610e41f4b71Sopenharmony_ci          .javaScriptAccess(true)
1611e41f4b71Sopenharmony_ci          // MultiWindowAccess needs to be enabled.
1612e41f4b71Sopenharmony_ci          .multiWindowAccess(true)
1613e41f4b71Sopenharmony_ci          .allowWindowOpenMethod(true)
1614e41f4b71Sopenharmony_ci          .onWindowNew((event) => {
1615e41f4b71Sopenharmony_ci            if (this.dialogController) {
1616e41f4b71Sopenharmony_ci              this.dialogController.close();
1617e41f4b71Sopenharmony_ci            }
1618e41f4b71Sopenharmony_ci            let popController: webview.WebviewController = new webview.WebviewController();
1619e41f4b71Sopenharmony_ci            this.dialogController = new CustomDialogController({
1620e41f4b71Sopenharmony_ci              builder: NewWebViewComp({ webviewController1: popController })
1621e41f4b71Sopenharmony_ci            })
1622e41f4b71Sopenharmony_ci            this.dialogController.open();
1623e41f4b71Sopenharmony_ci            // Return the WebviewController object corresponding to the new window to the <Web> kernel.
1624e41f4b71Sopenharmony_ci            // If opening a new window is not needed, set the parameter to null when calling the event.handler.setWebController API.
1625e41f4b71Sopenharmony_ci            // If the event.handler.setWebController API is not called, the render process will be blocked.
1626e41f4b71Sopenharmony_ci            event.handler.setWebController(popController);
1627e41f4b71Sopenharmony_ci          })
1628e41f4b71Sopenharmony_ci      }
1629e41f4b71Sopenharmony_ci    }
1630e41f4b71Sopenharmony_ci  }
1631e41f4b71Sopenharmony_ci  ```
1632e41f4b71Sopenharmony_ci
1633e41f4b71Sopenharmony_ci### mediaOptions<sup>10+</sup>
1634e41f4b71Sopenharmony_ci
1635e41f4b71Sopenharmony_cimediaOptions(options: WebMediaOptions)
1636e41f4b71Sopenharmony_ci
1637e41f4b71Sopenharmony_ciSets the web-based media playback policy, including the validity period for automatically resuming a paused web audio, and whether the audio of multiple **Web** instances in an application is exclusive.
1638e41f4b71Sopenharmony_ci
1639e41f4b71Sopenharmony_ci> **NOTE**
1640e41f4b71Sopenharmony_ci>
1641e41f4b71Sopenharmony_ci> - Audios in the same **Web** instance are considered as the same audio.
1642e41f4b71Sopenharmony_ci> - The media playback policy controls videos with an audio track.
1643e41f4b71Sopenharmony_ci> - After the parameter settings are updated, the playback must be started again for the settings to take effect.
1644e41f4b71Sopenharmony_ci> - It is recommended that you set the same **audioExclusive** value for all **Web** components.
1645e41f4b71Sopenharmony_ci> - Audio and video interruption takes effect within an app and between apps, and playback resumption takes effect only between apps.
1646e41f4b71Sopenharmony_ci
1647e41f4b71Sopenharmony_ci**Parameters**
1648e41f4b71Sopenharmony_ci
1649e41f4b71Sopenharmony_ci| Name    | Type                                 | Mandatory  | Default Value                                     | Description                                    |
1650e41f4b71Sopenharmony_ci| ------- | ------------------------------------- | ---- | ---------------------------------------- | ---------------------------------------- |
1651e41f4b71Sopenharmony_ci| options | [WebMediaOptions](#webmediaoptions10) | Yes   | {resumeInterval: 0, audioExclusive: true} | Web-based media playback policy. The default value of **resumeInterval** is **0**, indicating that the playback is not automatically resumed.|
1652e41f4b71Sopenharmony_ci
1653e41f4b71Sopenharmony_ci**Example**
1654e41f4b71Sopenharmony_ci
1655e41f4b71Sopenharmony_ci  ```ts
1656e41f4b71Sopenharmony_ci  // xxx.ets
1657e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1658e41f4b71Sopenharmony_ci
1659e41f4b71Sopenharmony_ci  @Entry
1660e41f4b71Sopenharmony_ci  @Component
1661e41f4b71Sopenharmony_ci  struct WebComponent {
1662e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1663e41f4b71Sopenharmony_ci    @State options: WebMediaOptions = {resumeInterval: 10, audioExclusive: true};
1664e41f4b71Sopenharmony_ci
1665e41f4b71Sopenharmony_ci    build() {
1666e41f4b71Sopenharmony_ci      Column() {
1667e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1668e41f4b71Sopenharmony_ci          .mediaOptions(this.options)
1669e41f4b71Sopenharmony_ci      }
1670e41f4b71Sopenharmony_ci    }
1671e41f4b71Sopenharmony_ci  }
1672e41f4b71Sopenharmony_ci  ```
1673e41f4b71Sopenharmony_ci
1674e41f4b71Sopenharmony_ci### javaScriptOnDocumentStart<sup>11+</sup>
1675e41f4b71Sopenharmony_ci
1676e41f4b71Sopenharmony_cijavaScriptOnDocumentStart(scripts: Array\<ScriptItem>)
1677e41f4b71Sopenharmony_ci
1678e41f4b71Sopenharmony_ciInjects a JavaScript script into the **Web** component. When the specified page or document starts to be loaded, the script is executed on any page whose source matches **scriptRules**.
1679e41f4b71Sopenharmony_ci
1680e41f4b71Sopenharmony_ci> **NOTE**
1681e41f4b71Sopenharmony_ci>
1682e41f4b71Sopenharmony_ci> - The script runs before any JavaScript code of the page, when the DOM tree may not have been loaded or rendered.
1683e41f4b71Sopenharmony_ci
1684e41f4b71Sopenharmony_ci**Parameters**
1685e41f4b71Sopenharmony_ci
1686e41f4b71Sopenharmony_ci| Name    | Type                               | Mandatory  | Default Value | Description              |
1687e41f4b71Sopenharmony_ci| ------- | ----------------------------------- | ---- | ---- | ------------------ |
1688e41f4b71Sopenharmony_ci| scripts | Array\<[ScriptItem](#scriptitem11)> | Yes   | -    | Script item array to be injected.|
1689e41f4b71Sopenharmony_ci
1690e41f4b71Sopenharmony_ci**Example in the .ets file**
1691e41f4b71Sopenharmony_ci
1692e41f4b71Sopenharmony_ci  ```ts
1693e41f4b71Sopenharmony_ci  // xxx.ets
1694e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1695e41f4b71Sopenharmony_ci
1696e41f4b71Sopenharmony_ci  @Entry
1697e41f4b71Sopenharmony_ci  @Component
1698e41f4b71Sopenharmony_ci  struct Index {
1699e41f4b71Sopenharmony_ci      controller: webview.WebviewController = new webview.WebviewController();
1700e41f4b71Sopenharmony_ci      private localStorage: string =
1701e41f4b71Sopenharmony_ci          "if (typeof(Storage) !== 'undefined') {" +
1702e41f4b71Sopenharmony_ci          "   localStorage.setItem('color', 'Red');" +
1703e41f4b71Sopenharmony_ci          "}";
1704e41f4b71Sopenharmony_ci      @State scripts: Array<ScriptItem> = [
1705e41f4b71Sopenharmony_ci          { script: this.localStorage, scriptRules: ["*"] }
1706e41f4b71Sopenharmony_ci      ];
1707e41f4b71Sopenharmony_ci
1708e41f4b71Sopenharmony_ci      build() {
1709e41f4b71Sopenharmony_ci          Column({ space: 20 }) {
1710e41f4b71Sopenharmony_ci              Web({ src: $rawfile('index.html'), controller: this.controller })
1711e41f4b71Sopenharmony_ci                  .javaScriptAccess(true)
1712e41f4b71Sopenharmony_ci                  .domStorageAccess(true)
1713e41f4b71Sopenharmony_ci                  .backgroundColor(Color.Grey)
1714e41f4b71Sopenharmony_ci                  .javaScriptOnDocumentStart(this.scripts)
1715e41f4b71Sopenharmony_ci                  .width('100%')
1716e41f4b71Sopenharmony_ci                  .height('100%')
1717e41f4b71Sopenharmony_ci          }
1718e41f4b71Sopenharmony_ci      }
1719e41f4b71Sopenharmony_ci  }
1720e41f4b71Sopenharmony_ci  ```
1721e41f4b71Sopenharmony_ci**Example in the HTML file**
1722e41f4b71Sopenharmony_ci
1723e41f4b71Sopenharmony_ci```html
1724e41f4b71Sopenharmony_ci<!-- index.html -->
1725e41f4b71Sopenharmony_ci<!DOCTYPE html>
1726e41f4b71Sopenharmony_ci<html>
1727e41f4b71Sopenharmony_ci  <head>
1728e41f4b71Sopenharmony_ci    <meta charset="utf-8">
1729e41f4b71Sopenharmony_ci  </head>
1730e41f4b71Sopenharmony_ci  <body style="font-size: 30px;" onload='bodyOnLoadLocalStorage()'>
1731e41f4b71Sopenharmony_ci      Hello world!
1732e41f4b71Sopenharmony_ci      <div id="result"></div>
1733e41f4b71Sopenharmony_ci  </body>
1734e41f4b71Sopenharmony_ci  <script type="text/javascript">
1735e41f4b71Sopenharmony_ci    function bodyOnLoadLocalStorage() {
1736e41f4b71Sopenharmony_ci      if (typeof(Storage) !== 'undefined') {
1737e41f4b71Sopenharmony_ci        document.getElementById('result').innerHTML = localStorage.getItem('color');
1738e41f4b71Sopenharmony_ci      } else {
1739e41f4b71Sopenharmony_ci        document.getElementById('result').innerHTML = 'Your browser does not support localStorage.';
1740e41f4b71Sopenharmony_ci      }
1741e41f4b71Sopenharmony_ci    }
1742e41f4b71Sopenharmony_ci  </script>
1743e41f4b71Sopenharmony_ci</html>
1744e41f4b71Sopenharmony_ci```
1745e41f4b71Sopenharmony_ci
1746e41f4b71Sopenharmony_ci### javaScriptOnDocumentEnd<sup>11+</sup>
1747e41f4b71Sopenharmony_ci
1748e41f4b71Sopenharmony_cijavaScriptOnDocumentEnd(scripts: Array\<ScriptItem>)
1749e41f4b71Sopenharmony_ci
1750e41f4b71Sopenharmony_ciInjects a JavaScript script into the **Web** component. When the specified page or document has been loaded, the script is executed on any page whose source matches **scriptRules**.
1751e41f4b71Sopenharmony_ci
1752e41f4b71Sopenharmony_ci> **NOTE**
1753e41f4b71Sopenharmony_ci>
1754e41f4b71Sopenharmony_ci> - The script runs before any JavaScript code of the page, when the DOM tree has been loaded and rendered.
1755e41f4b71Sopenharmony_ci
1756e41f4b71Sopenharmony_ci**Parameters**
1757e41f4b71Sopenharmony_ci
1758e41f4b71Sopenharmony_ci| Name    | Type                               | Mandatory  | Default Value | Description              |
1759e41f4b71Sopenharmony_ci| ------- | ----------------------------------- | ---- | ---- | ------------------ |
1760e41f4b71Sopenharmony_ci| scripts | Array\<[ScriptItem](#scriptitem11)> | Yes   | -    | Script item array to be injected.|
1761e41f4b71Sopenharmony_ci
1762e41f4b71Sopenharmony_ci**Example**
1763e41f4b71Sopenharmony_ci
1764e41f4b71Sopenharmony_ci  ```ts
1765e41f4b71Sopenharmony_ci// xxx.ets
1766e41f4b71Sopenharmony_ciimport { webview } from '@kit.ArkWeb';
1767e41f4b71Sopenharmony_ci
1768e41f4b71Sopenharmony_ci@Entry
1769e41f4b71Sopenharmony_ci@Component
1770e41f4b71Sopenharmony_cistruct Index {
1771e41f4b71Sopenharmony_ci  controller: webview.WebviewController = new webview.WebviewController();
1772e41f4b71Sopenharmony_ci  private jsStr: string =
1773e41f4b71Sopenharmony_ci    "window.document.getElementById(\"result\").innerHTML = 'this is msg from javaScriptOnDocumentEnd'";
1774e41f4b71Sopenharmony_ci  @State scripts: Array<ScriptItem> = [
1775e41f4b71Sopenharmony_ci    { script: this.jsStr, scriptRules: ["*"] }
1776e41f4b71Sopenharmony_ci  ];
1777e41f4b71Sopenharmony_ci
1778e41f4b71Sopenharmony_ci  build() {
1779e41f4b71Sopenharmony_ci    Column({ space: 20 }) {
1780e41f4b71Sopenharmony_ci      Web({ src: $rawfile('index.html'), controller: this.controller })
1781e41f4b71Sopenharmony_ci        .javaScriptAccess(true)
1782e41f4b71Sopenharmony_ci        .domStorageAccess(true)
1783e41f4b71Sopenharmony_ci        .backgroundColor(Color.Grey)
1784e41f4b71Sopenharmony_ci        .javaScriptOnDocumentEnd(this.scripts)
1785e41f4b71Sopenharmony_ci        .width('100%')
1786e41f4b71Sopenharmony_ci        .height('100%')
1787e41f4b71Sopenharmony_ci    }
1788e41f4b71Sopenharmony_ci  }
1789e41f4b71Sopenharmony_ci}
1790e41f4b71Sopenharmony_ci  ```
1791e41f4b71Sopenharmony_ci
1792e41f4b71Sopenharmony_ci```html
1793e41f4b71Sopenharmony_ci<!DOCTYPE html>
1794e41f4b71Sopenharmony_ci<html>
1795e41f4b71Sopenharmony_ci<head>
1796e41f4b71Sopenharmony_ci    <meta charset="utf-8">
1797e41f4b71Sopenharmony_ci</head>
1798e41f4b71Sopenharmony_ci<body style="font-size: 30px;">
1799e41f4b71Sopenharmony_ciHello world!
1800e41f4b71Sopenharmony_ci<div id="result">test msg</div>
1801e41f4b71Sopenharmony_ci</body>
1802e41f4b71Sopenharmony_ci</html>
1803e41f4b71Sopenharmony_ci```
1804e41f4b71Sopenharmony_ci
1805e41f4b71Sopenharmony_ci### layoutMode<sup>11+</sup>
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_cilayoutMode(mode: WebLayoutMode)
1808e41f4b71Sopenharmony_ci
1809e41f4b71Sopenharmony_ciSets the web layout mode.
1810e41f4b71Sopenharmony_ci
1811e41f4b71Sopenharmony_ci> **NOTE**
1812e41f4b71Sopenharmony_ci>
1813e41f4b71Sopenharmony_ci> Currently, only two web layout modes are supported: **WebLayoutMode.NONE** and **WebLayoutMode.FIT_CONTENT**.
1814e41f4b71Sopenharmony_ci>
1815e41f4b71Sopenharmony_ci> The following restrictions apply with the usage of **WebLayoutMode.FIT_CONTENT**:
1816e41f4b71Sopenharmony_ci> - If the web content is wider or longer than 8000 px, specify the **RenderMode.SYNC_RENDER** mode when creating the **Web** component; otherwise, the screen may be blank.
1817e41f4b71Sopenharmony_ci> - After the **Web** component is created, dynamic switching of the **layoutMode** is not supported.
1818e41f4b71Sopenharmony_ci> - The width and height of the **Web** component cannot exceed 500,000 px each.
1819e41f4b71Sopenharmony_ci> - Frequent changes to the page width and height will trigger a re-layout of the **Web** component, which can affect the user experience.
1820e41f4b71Sopenharmony_ci
1821e41f4b71Sopenharmony_ci**Parameters**
1822e41f4b71Sopenharmony_ci
1823e41f4b71Sopenharmony_ci| Name | Type                                 | Mandatory  | Default Value               | Description                 |
1824e41f4b71Sopenharmony_ci| ---- | ------------------------------------- | ---- | ------------------ | --------------------- |
1825e41f4b71Sopenharmony_ci| mode | [WebLayoutMode](#weblayoutmode11) | Yes   | WebLayoutMode.NONE | Web layout mode.|
1826e41f4b71Sopenharmony_ci
1827e41f4b71Sopenharmony_ci**Example**
1828e41f4b71Sopenharmony_ci
1829e41f4b71Sopenharmony_ci  1. After specifying the **layoutMode** as **WebLayoutMode.FIT_CONTENT**, you must explicitly specify **renderMode** as **RenderMode.SYNC_RENDER**.
1830e41f4b71Sopenharmony_ci  ```ts
1831e41f4b71Sopenharmony_ci  // xxx.ets
1832e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1833e41f4b71Sopenharmony_ci
1834e41f4b71Sopenharmony_ci  @Entry
1835e41f4b71Sopenharmony_ci  @Component
1836e41f4b71Sopenharmony_ci  struct WebComponent {
1837e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1838e41f4b71Sopenharmony_ci    @State mode: WebLayoutMode = WebLayoutMode.FIT_CONTENT;
1839e41f4b71Sopenharmony_ci
1840e41f4b71Sopenharmony_ci    build() {
1841e41f4b71Sopenharmony_ci      Column() {
1842e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller, renderMode: RenderMode.SYNC_RENDER })
1843e41f4b71Sopenharmony_ci          .layoutMode(this.mode)
1844e41f4b71Sopenharmony_ci      }
1845e41f4b71Sopenharmony_ci    }
1846e41f4b71Sopenharmony_ci  }
1847e41f4b71Sopenharmony_ci  ```
1848e41f4b71Sopenharmony_ci
1849e41f4b71Sopenharmony_ci  2. After specifying the **layoutMode** as **WebLayoutMode.FIT_CONTENT**, you are advised to specify **overScrollMode** as **OverScrollMode.NEVER**.
1850e41f4b71Sopenharmony_ci  ```ts
1851e41f4b71Sopenharmony_ci  // xxx.ets
1852e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1853e41f4b71Sopenharmony_ci
1854e41f4b71Sopenharmony_ci  @Entry
1855e41f4b71Sopenharmony_ci  @Component
1856e41f4b71Sopenharmony_ci  struct WebComponent {
1857e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1858e41f4b71Sopenharmony_ci    @State layoutMode: WebLayoutMode = WebLayoutMode.FIT_CONTENT;
1859e41f4b71Sopenharmony_ci    @State overScrollMode: OverScrollMode = OverScrollMode.NEVER;
1860e41f4b71Sopenharmony_ci
1861e41f4b71Sopenharmony_ci    build() {
1862e41f4b71Sopenharmony_ci      Column() {
1863e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller, renderMode: RenderMode.SYNC_RENDER })
1864e41f4b71Sopenharmony_ci          .layoutMode(this.layoutMode)
1865e41f4b71Sopenharmony_ci          .overScrollMode(this.overScrollMode)
1866e41f4b71Sopenharmony_ci      }
1867e41f4b71Sopenharmony_ci    }
1868e41f4b71Sopenharmony_ci  }
1869e41f4b71Sopenharmony_ci  ```
1870e41f4b71Sopenharmony_ci
1871e41f4b71Sopenharmony_ci### nestedScroll<sup>11+</sup>
1872e41f4b71Sopenharmony_ci
1873e41f4b71Sopenharmony_cinestedScroll(value: NestedScrollOptions)
1874e41f4b71Sopenharmony_ci
1875e41f4b71Sopenharmony_ciSets nested scrolling options.
1876e41f4b71Sopenharmony_ci
1877e41f4b71Sopenharmony_ci> **NOTE**
1878e41f4b71Sopenharmony_ci>
1879e41f4b71Sopenharmony_ci> - You can set the nested scrolling mode in both forward and backward directions to implement scrolling linkage with the parent component.
1880e41f4b71Sopenharmony_ci> - You can set separate nested scrolling modes for the forward and backward directions.
1881e41f4b71Sopenharmony_ci> - The default mode for **scrollForward** and **scrollBackward** is **NestedScrollMode.SELF_FIRST**.
1882e41f4b71Sopenharmony_ci> - Containers that support nested scrolling: **\<Grid>**, **\<List>**, **\<Scroll>**, **\<Swiper>**, **\<Tabs>**, **\<WaterFlow>**.
1883e41f4b71Sopenharmony_ci> - Input sources that support nested scrolling: gestures, mouse device, and touchpad.
1884e41f4b71Sopenharmony_ci> - In nested scrolling scenarios, since the **Web** component's over-scrolling to the edge will trigger the over-scroll bounce effect first, it is recommended that you set **overScrollMode** to **OverScrollMode.NEVER** to avoid undermining the user experience.
1885e41f4b71Sopenharmony_ci
1886e41f4b71Sopenharmony_ci**Parameters**
1887e41f4b71Sopenharmony_ci
1888e41f4b71Sopenharmony_ci| Name  | Type                                    | Mandatory  | Description            |
1889e41f4b71Sopenharmony_ci| ----- | ---------------------------------------- | ---- | ---------------- |
1890e41f4b71Sopenharmony_ci| value | [NestedScrollOptions](#nestedscrolloptions11) | Yes   | Nested scrolling options.|
1891e41f4b71Sopenharmony_ci
1892e41f4b71Sopenharmony_ci**Example**
1893e41f4b71Sopenharmony_ci
1894e41f4b71Sopenharmony_ci  ```ts
1895e41f4b71Sopenharmony_ci  // xxx.ets
1896e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1897e41f4b71Sopenharmony_ci  @Entry
1898e41f4b71Sopenharmony_ci  @Component
1899e41f4b71Sopenharmony_ci  struct WebComponent {
1900e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1901e41f4b71Sopenharmony_ci
1902e41f4b71Sopenharmony_ci    build() {
1903e41f4b71Sopenharmony_ci      Column() {
1904e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1905e41f4b71Sopenharmony_ci          .nestedScroll({
1906e41f4b71Sopenharmony_ci            scrollForward: NestedScrollMode.SELF_FIRST,
1907e41f4b71Sopenharmony_ci            scrollBackward: NestedScrollMode.SELF_FIRST,
1908e41f4b71Sopenharmony_ci          })
1909e41f4b71Sopenharmony_ci      }
1910e41f4b71Sopenharmony_ci    }
1911e41f4b71Sopenharmony_ci  }
1912e41f4b71Sopenharmony_ci  ```
1913e41f4b71Sopenharmony_ci### enableNativeEmbedMode<sup>11+</sup>
1914e41f4b71Sopenharmony_cienableNativeEmbedMode(mode: boolean)
1915e41f4b71Sopenharmony_ci
1916e41f4b71Sopenharmony_ciSpecifies whether to enable the same-layer rendering feature. By default, this feature is disabled.
1917e41f4b71Sopenharmony_ci
1918e41f4b71Sopenharmony_ci
1919e41f4b71Sopenharmony_ci**Parameters**
1920e41f4b71Sopenharmony_ci
1921e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory  | Default Value               | Description            |
1922e41f4b71Sopenharmony_ci| ----- | ---------------------------------------- | ---- | ------------------| ---------------- |
1923e41f4b71Sopenharmony_ci| mode |  boolean | Yes   | false | Whether to enable the same-layer rendering feature.|
1924e41f4b71Sopenharmony_ci
1925e41f4b71Sopenharmony_ci**Example**
1926e41f4b71Sopenharmony_ci
1927e41f4b71Sopenharmony_ci  ```ts
1928e41f4b71Sopenharmony_ci  // xxx.ets
1929e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1930e41f4b71Sopenharmony_ci  @Entry
1931e41f4b71Sopenharmony_ci  @Component
1932e41f4b71Sopenharmony_ci  struct WebComponent {
1933e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
1934e41f4b71Sopenharmony_ci
1935e41f4b71Sopenharmony_ci    build() {
1936e41f4b71Sopenharmony_ci      Column() {
1937e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
1938e41f4b71Sopenharmony_ci          .enableNativeEmbedMode(true)
1939e41f4b71Sopenharmony_ci      }
1940e41f4b71Sopenharmony_ci    }
1941e41f4b71Sopenharmony_ci  }
1942e41f4b71Sopenharmony_ci  ```
1943e41f4b71Sopenharmony_ci### forceDisplayScrollBar<sup>14+</sup>
1944e41f4b71Sopenharmony_ci
1945e41f4b71Sopenharmony_ciforceDisplayScrollBar(enabled: boolean)
1946e41f4b71Sopenharmony_ci
1947e41f4b71Sopenharmony_ci
1948e41f4b71Sopenharmony_ciSets whether the scroll bar is always visible. By default, it is not always visible. Under the always-visible settings, when the page size exceeds one page, the scroll bar appears and remains visible.
1949e41f4b71Sopenharmony_ci
1950e41f4b71Sopenharmony_ci
1951e41f4b71Sopenharmony_ci**Parameters**
1952e41f4b71Sopenharmony_ci
1953e41f4b71Sopenharmony_ci| Name | Type| Mandatory| Default Value| Description          |
1954e41f4b71Sopenharmony_ci| ------- | -------- | ---- | ------ | ------------------ |
1955e41f4b71Sopenharmony_ci| enabled | boolean  | Yes  | false  | Whether the scroll bar is always visible.|
1956e41f4b71Sopenharmony_ci
1957e41f4b71Sopenharmony_ci
1958e41f4b71Sopenharmony_ci**Example**
1959e41f4b71Sopenharmony_ci
1960e41f4b71Sopenharmony_ci  ```ts
1961e41f4b71Sopenharmony_ci  // xxx.ets
1962e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
1963e41f4b71Sopenharmony_ci
1964e41f4b71Sopenharmony_ci  @Entry
1965e41f4b71Sopenharmony_ci  @Component
1966e41f4b71Sopenharmony_ci  struct WebComponent {
1967e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController()
1968e41f4b71Sopenharmony_ci
1969e41f4b71Sopenharmony_ci    build() {
1970e41f4b71Sopenharmony_ci      Column() {
1971e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
1972e41f4b71Sopenharmony_ci          .forceDisplayScrollBar(true)
1973e41f4b71Sopenharmony_ci      }
1974e41f4b71Sopenharmony_ci    }
1975e41f4b71Sopenharmony_ci  }
1976e41f4b71Sopenharmony_ci  ```
1977e41f4b71Sopenharmony_ci
1978e41f4b71Sopenharmony_ci  HTML file to be loaded:
1979e41f4b71Sopenharmony_ci  ```html
1980e41f4b71Sopenharmony_ci  <!--index.html-->
1981e41f4b71Sopenharmony_ci  <!DOCTYPE html>
1982e41f4b71Sopenharmony_ci  <html>
1983e41f4b71Sopenharmony_ci  <head>
1984e41f4b71Sopenharmony_ci      <meta name="viewport" content="width=device-width, initial-scale=1.0">
1985e41f4b71Sopenharmony_ci      <title>Demo</title>
1986e41f4b71Sopenharmony_ci      <style>
1987e41f4b71Sopenharmony_ci        body {
1988e41f4b71Sopenharmony_ci          width:2560px;
1989e41f4b71Sopenharmony_ci          height:2560px;
1990e41f4b71Sopenharmony_ci          padding-right:170px;
1991e41f4b71Sopenharmony_ci          padding-left:170px;
1992e41f4b71Sopenharmony_ci          border:5px solid blueviolet
1993e41f4b71Sopenharmony_ci        }
1994e41f4b71Sopenharmony_ci      </style>
1995e41f4b71Sopenharmony_ci  </head>
1996e41f4b71Sopenharmony_ci  <body>
1997e41f4b71Sopenharmony_ci  Scroll Test
1998e41f4b71Sopenharmony_ci  </body>
1999e41f4b71Sopenharmony_ci  </html>
2000e41f4b71Sopenharmony_ci  ```
2001e41f4b71Sopenharmony_ci### registerNativeEmbedRule<sup>12+</sup>
2002e41f4b71Sopenharmony_ciregisterNativeEmbedRule(tag: string, type: string)
2003e41f4b71Sopenharmony_ci
2004e41f4b71Sopenharmony_ciRegisters the HTML tag name and type for same-layer rendering. The tag name only supports **object** and **embed**. The tag type can be any non-empty string, case-insensitive. If the standard type is the same as the standard type of **object** or **embed**, the ArkWeb engine will recognize it as a non-same-layer tag. This API is also controlled by the **enableNativeEmbedMode** API and does not take effect if same-layer rendering is not enabled. When this API is not used, the ArkWeb engine recognizes the **embed** tags with the "native/" prefix as same-layer tags.
2005e41f4b71Sopenharmony_ci
2006e41f4b71Sopenharmony_ci**Parameters**
2007e41f4b71Sopenharmony_ci
2008e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description            |
2009e41f4b71Sopenharmony_ci|------|--------| ---- |------|------------------|
2010e41f4b71Sopenharmony_ci| tag  | string | Yes   | ""   | Tag name.            |
2011e41f4b71Sopenharmony_ci| type | string | Yes   | ""   | Tag type. It is used by the ArkWeb engine for prefix matching.|
2012e41f4b71Sopenharmony_ci
2013e41f4b71Sopenharmony_ci**Example**
2014e41f4b71Sopenharmony_ci
2015e41f4b71Sopenharmony_ci  ```ts
2016e41f4b71Sopenharmony_ci  // xxx.ets
2017e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2018e41f4b71Sopenharmony_ci
2019e41f4b71Sopenharmony_ci  @Entry
2020e41f4b71Sopenharmony_ci  @Component
2021e41f4b71Sopenharmony_ci  struct WebComponent {
2022e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2023e41f4b71Sopenharmony_ci
2024e41f4b71Sopenharmony_ci    build() {
2025e41f4b71Sopenharmony_ci      Column() {
2026e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
2027e41f4b71Sopenharmony_ci          .enableNativeEmbedMode(true)
2028e41f4b71Sopenharmony_ci          .registerNativeEmbedRule("object", "application/view")
2029e41f4b71Sopenharmony_ci      }
2030e41f4b71Sopenharmony_ci    }
2031e41f4b71Sopenharmony_ci  }
2032e41f4b71Sopenharmony_ci  ```
2033e41f4b71Sopenharmony_ci### defaultTextEncodingFormat<sup>12+</sup>
2034e41f4b71Sopenharmony_ci
2035e41f4b71Sopenharmony_cidefaultTextEncodingFormat(textEncodingFormat: string)
2036e41f4b71Sopenharmony_ci
2037e41f4b71Sopenharmony_ciSets the default character encoding for web pages.
2038e41f4b71Sopenharmony_ci
2039e41f4b71Sopenharmony_ci**Parameters**
2040e41f4b71Sopenharmony_ci
2041e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description                                    |
2042e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ---------------------------------------- |
2043e41f4b71Sopenharmony_ci| textEncodingFormat | string | Yes   | "UTF-8"   | Default character encoding.|
2044e41f4b71Sopenharmony_ci
2045e41f4b71Sopenharmony_ci  **Example**
2046e41f4b71Sopenharmony_ci
2047e41f4b71Sopenharmony_ci  ```ts
2048e41f4b71Sopenharmony_ci  // xxx.ets
2049e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2050e41f4b71Sopenharmony_ci
2051e41f4b71Sopenharmony_ci  @Entry
2052e41f4b71Sopenharmony_ci  @Component
2053e41f4b71Sopenharmony_ci  struct WebComponent {
2054e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2055e41f4b71Sopenharmony_ci
2056e41f4b71Sopenharmony_ci    build() {
2057e41f4b71Sopenharmony_ci      Column() {
2058e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
2059e41f4b71Sopenharmony_ci          // Set the height.
2060e41f4b71Sopenharmony_ci          .height(500)
2061e41f4b71Sopenharmony_ci          .defaultTextEncodingFormat("UTF-8")
2062e41f4b71Sopenharmony_ci          .javaScriptAccess(true)
2063e41f4b71Sopenharmony_ci      }
2064e41f4b71Sopenharmony_ci    }
2065e41f4b71Sopenharmony_ci  }
2066e41f4b71Sopenharmony_ci  ```
2067e41f4b71Sopenharmony_ci
2068e41f4b71Sopenharmony_ci```html
2069e41f4b71Sopenharmony_ci
2070e41f4b71Sopenharmony_ci<!doctype html>
2071e41f4b71Sopenharmony_ci<html>
2072e41f4b71Sopenharmony_ci<head>
2073e41f4b71Sopenharmony_ci    <meta name="viewport" content="width=device-width" />
2074e41f4b71Sopenharmony_ci    <title>My test html5 page</title>
2075e41f4b71Sopenharmony_ci</head>
2076e41f4b71Sopenharmony_ci<body>
2077e41f4b71Sopenharmony_ci    Hello world!
2078e41f4b71Sopenharmony_ci</body>
2079e41f4b71Sopenharmony_ci</html>
2080e41f4b71Sopenharmony_ci```
2081e41f4b71Sopenharmony_ci### metaViewport<sup>12+</sup>
2082e41f4b71Sopenharmony_ci
2083e41f4b71Sopenharmony_cimetaViewport(enable: boolean)
2084e41f4b71Sopenharmony_ci
2085e41f4b71Sopenharmony_ciSets whether the **viewport** property of the **meta** tag is enabled.
2086e41f4b71Sopenharmony_ci
2087e41f4b71Sopenharmony_ci> **NOTE**
2088e41f4b71Sopenharmony_ci>
2089e41f4b71Sopenharmony_ci> - If this parameter is set to **false**, the **viewport** property of the **meta** tag is not enabled. This means that the property will not be parsed and a default layout will be used.
2090e41f4b71Sopenharmony_ci> - If this parameter is set to **true**, the **viewport** property of the **meta** tag is enabled. This means that the property will be parsed and used for the layout.
2091e41f4b71Sopenharmony_ci> - If set to an invalid value, this parameter does not take effect.
2092e41f4b71Sopenharmony_ci> - If the device is 2-in-1, the **viewport** property is not supported. This means that, regardless of whether this parameter is set to **true** or **false**, the **viewport** property will not be parsed and a default layout will be used.
2093e41f4b71Sopenharmony_ci
2094e41f4b71Sopenharmony_ci**Parameters**
2095e41f4b71Sopenharmony_ci
2096e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Default Value| Description                        |
2097e41f4b71Sopenharmony_ci| ------ | -------- | ---- | ------ | -------------------------------- |
2098e41f4b71Sopenharmony_ci| enable | boolean  | Yes  | true   | Whether the **viewport** property of the **meta** tag is enabled.|
2099e41f4b71Sopenharmony_ci
2100e41f4b71Sopenharmony_ci**Example**
2101e41f4b71Sopenharmony_ci
2102e41f4b71Sopenharmony_ci  ```ts
2103e41f4b71Sopenharmony_ci// xxx.ets
2104e41f4b71Sopenharmony_ciimport { webview } from '@kit.ArkWeb';
2105e41f4b71Sopenharmony_ci
2106e41f4b71Sopenharmony_ci@Entry
2107e41f4b71Sopenharmony_ci@Component
2108e41f4b71Sopenharmony_cistruct WebComponent {
2109e41f4b71Sopenharmony_ci  controller: webview.WebviewController = new webview.WebviewController();
2110e41f4b71Sopenharmony_ci
2111e41f4b71Sopenharmony_ci  build() {
2112e41f4b71Sopenharmony_ci    Column() {
2113e41f4b71Sopenharmony_ci      Web({ src: $rawfile('index.html'), controller: this.controller })
2114e41f4b71Sopenharmony_ci        .metaViewport(true)
2115e41f4b71Sopenharmony_ci    }
2116e41f4b71Sopenharmony_ci  }
2117e41f4b71Sopenharmony_ci}
2118e41f4b71Sopenharmony_ci  ```
2119e41f4b71Sopenharmony_ci
2120e41f4b71Sopenharmony_ci```html
2121e41f4b71Sopenharmony_ci<!doctype html>
2122e41f4b71Sopenharmony_ci<html>
2123e41f4b71Sopenharmony_ci<head>
2124e41f4b71Sopenharmony_ci    <meta name="viewport" content="width=device-width, initial-scale=1.0">
2125e41f4b71Sopenharmony_ci</head>
2126e41f4b71Sopenharmony_ci<body>
2127e41f4b71Sopenharmony_ci	<p>Hello world! </p>
2128e41f4b71Sopenharmony_ci</body>
2129e41f4b71Sopenharmony_ci</html>
2130e41f4b71Sopenharmony_ci```
2131e41f4b71Sopenharmony_ci### textAutosizing<sup>12+</sup>
2132e41f4b71Sopenharmony_ci
2133e41f4b71Sopenharmony_citextAutosizing(textAutosizing: boolean)
2134e41f4b71Sopenharmony_ci
2135e41f4b71Sopenharmony_ciSets whether automatic text resizing is enabled.
2136e41f4b71Sopenharmony_ci
2137e41f4b71Sopenharmony_ci**Parameters**
2138e41f4b71Sopenharmony_ci
2139e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description                                    |
2140e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ---------------------------------------- |
2141e41f4b71Sopenharmony_ci| textAutosizing | boolean | Yes   | true   | Whether automatic text resizing is enabled.|
2142e41f4b71Sopenharmony_ci
2143e41f4b71Sopenharmony_ci  **Example**
2144e41f4b71Sopenharmony_ci
2145e41f4b71Sopenharmony_ci  ```ts
2146e41f4b71Sopenharmony_ci  // xxx.ets
2147e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2148e41f4b71Sopenharmony_ci
2149e41f4b71Sopenharmony_ci  @Entry
2150e41f4b71Sopenharmony_ci  @Component
2151e41f4b71Sopenharmony_ci  struct WebComponent {
2152e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2153e41f4b71Sopenharmony_ci
2154e41f4b71Sopenharmony_ci    build() {
2155e41f4b71Sopenharmony_ci      Column() {
2156e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
2157e41f4b71Sopenharmony_ci          .textAutosizing(false)
2158e41f4b71Sopenharmony_ci      }
2159e41f4b71Sopenharmony_ci    }
2160e41f4b71Sopenharmony_ci  }
2161e41f4b71Sopenharmony_ci  ```
2162e41f4b71Sopenharmony_ci### enableNativeMediaPlayer<sup>12+</sup>
2163e41f4b71Sopenharmony_ci
2164e41f4b71Sopenharmony_cienableNativeMediaPlayer(config: NativeMediaPlayerConfig)
2165e41f4b71Sopenharmony_ci
2166e41f4b71Sopenharmony_ciEnable the [application takeover of web media playback feature](../../web/app-takeovers-web-media.md).
2167e41f4b71Sopenharmony_ci
2168e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Web.Webview.Core
2169e41f4b71Sopenharmony_ci
2170e41f4b71Sopenharmony_ci**Parameters**
2171e41f4b71Sopenharmony_ci
2172e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description|
2173e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ---------------------|
2174e41f4b71Sopenharmony_ci| config | [NativeMediaPlayerConfig](#nativemediaplayerconfig12) | Yes   |  {enable: false, shouldOverlay: false} | **enable**: whether to enable the feature.<br> **shouldOverlay**: whether the image of the video player taken over by the application will overlay the web page content, if this feature is enabled.|
2175e41f4b71Sopenharmony_ci
2176e41f4b71Sopenharmony_ci  **Example**
2177e41f4b71Sopenharmony_ci
2178e41f4b71Sopenharmony_ci  ```ts
2179e41f4b71Sopenharmony_ci  // xxx.ets
2180e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2181e41f4b71Sopenharmony_ci
2182e41f4b71Sopenharmony_ci  @Entry
2183e41f4b71Sopenharmony_ci  @Component
2184e41f4b71Sopenharmony_ci  struct WebComponent {
2185e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2186e41f4b71Sopenharmony_ci
2187e41f4b71Sopenharmony_ci    build() {
2188e41f4b71Sopenharmony_ci      Column() {
2189e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
2190e41f4b71Sopenharmony_ci          .enableNativeMediaPlayer({enable: true, shouldOverlay: false})
2191e41f4b71Sopenharmony_ci      }
2192e41f4b71Sopenharmony_ci    }
2193e41f4b71Sopenharmony_ci  }
2194e41f4b71Sopenharmony_ci  ```
2195e41f4b71Sopenharmony_ci
2196e41f4b71Sopenharmony_ci### selectionMenuOptions<sup>12+</sup>
2197e41f4b71Sopenharmony_ci
2198e41f4b71Sopenharmony_ciselectionMenuOptions(expandedMenuOptions: Array\<ExpandedMenuItemOptions>)
2199e41f4b71Sopenharmony_ci
2200e41f4b71Sopenharmony_ciSets the extended options of the custom context menu on selection, including the text content, icon, and callback.
2201e41f4b71Sopenharmony_ci
2202e41f4b71Sopenharmony_ciThe API only supports the selection of plain text; if the selected content contains images or other non-text elements, the **action** information may display garbled content.
2203e41f4b71Sopenharmony_ci
2204e41f4b71Sopenharmony_ci**Parameters**
2205e41f4b71Sopenharmony_ci
2206e41f4b71Sopenharmony_ci| Name             | Type                                                        | Description         |
2207e41f4b71Sopenharmony_ci| ------------------- | ----------------------------------------------------------   | ------------- |
2208e41f4b71Sopenharmony_ci| expandedMenuOptions | Array<[ExpandedMenuItemOptions](#expandedmenuitemoptions12)> | Extended options of the custom context menu on selection.<br>The number of menu options, menu content size, and start icon size must be the same as those of the ArkUI [\<Menu>](../apis-arkui/arkui-ts/ts-basic-components-menu.md) component.|
2209e41f4b71Sopenharmony_ci
2210e41f4b71Sopenharmony_ci**Example**
2211e41f4b71Sopenharmony_ci
2212e41f4b71Sopenharmony_ci  ```ts
2213e41f4b71Sopenharmony_ci  // xxx.ets
2214e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2215e41f4b71Sopenharmony_ci
2216e41f4b71Sopenharmony_ci  @Entry
2217e41f4b71Sopenharmony_ci  @Component
2218e41f4b71Sopenharmony_ci  struct WebComponent {
2219e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2220e41f4b71Sopenharmony_ci    @State menuOptionArray: Array<ExpandedMenuItemOptions> = [
2221e41f4b71Sopenharmony_ci      {content: 'Apple', startIcon: $r('app.media.icon'), action: (selectedText) => {
2222e41f4b71Sopenharmony_ci        console.info('select info ' + selectedText.toString());
2223e41f4b71Sopenharmony_ci      }},
2224e41f4b71Sopenharmony_ci      {content: 'Banana', startIcon: $r('app.media.icon'), action: (selectedText) => {
2225e41f4b71Sopenharmony_ci        console.info('select info ' + selectedText.toString());
2226e41f4b71Sopenharmony_ci      }}
2227e41f4b71Sopenharmony_ci    ];
2228e41f4b71Sopenharmony_ci
2229e41f4b71Sopenharmony_ci    build() {
2230e41f4b71Sopenharmony_ci      Column() {
2231e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
2232e41f4b71Sopenharmony_ci        .selectionMenuOptions(this.menuOptionArray)
2233e41f4b71Sopenharmony_ci      }
2234e41f4b71Sopenharmony_ci    }
2235e41f4b71Sopenharmony_ci  }
2236e41f4b71Sopenharmony_ci  ```
2237e41f4b71Sopenharmony_ci
2238e41f4b71Sopenharmony_ci  HTML file to be loaded:
2239e41f4b71Sopenharmony_ci  ```html
2240e41f4b71Sopenharmony_ci  <!--index.html-->
2241e41f4b71Sopenharmony_ci  <!DOCTYPE html>
2242e41f4b71Sopenharmony_ci  <html>
2243e41f4b71Sopenharmony_ci  <head>
2244e41f4b71Sopenharmony_ci    <title>Test Web Page</title>
2245e41f4b71Sopenharmony_ci  </head>
2246e41f4b71Sopenharmony_ci  <body>
2247e41f4b71Sopenharmony_ci    <h1>selectionMenuOptions Demo</h1>
2248e41f4b71Sopenharmony_ci    <span>selection menu options</span>
2249e41f4b71Sopenharmony_ci  </body>
2250e41f4b71Sopenharmony_ci  </html>
2251e41f4b71Sopenharmony_ci  ```
2252e41f4b71Sopenharmony_ci
2253e41f4b71Sopenharmony_ci### keyboardAvoidMode<sup>12+</sup>
2254e41f4b71Sopenharmony_ci
2255e41f4b71Sopenharmony_cikeyboardAvoidMode(mode: WebKeyboardAvoidMode)
2256e41f4b71Sopenharmony_ci
2257e41f4b71Sopenharmony_ciSets the custom soft keyboard avoidance mode.
2258e41f4b71Sopenharmony_ci
2259e41f4b71Sopenharmony_ciIf the keyboard avoidance mode set in **UIContext** is [KeyboardAvoidMode.RESIZE](../apis-arkui/js-apis-arkui-UIContext.md#keyboardavoidmode11), this API does not take effect.
2260e41f4b71Sopenharmony_ci
2261e41f4b71Sopenharmony_ci**Parameters**
2262e41f4b71Sopenharmony_ci
2263e41f4b71Sopenharmony_ci| Name             | Type                             | Mandatory  | Description         |
2264e41f4b71Sopenharmony_ci| ------------------- | ------------------------------   | ------ | ------------- |
2265e41f4b71Sopenharmony_ci| mode | [WebKeyboardAvoidMode](#webkeyboardavoidmode12) | Yes    | Web soft keyboard avoidance mode.<br>Default value: **WebKeyboardAvoidMode.RESIZE_CONTENT**|
2266e41f4b71Sopenharmony_ci
2267e41f4b71Sopenharmony_ci**Example**
2268e41f4b71Sopenharmony_ci
2269e41f4b71Sopenharmony_ci  ```ts
2270e41f4b71Sopenharmony_ci  // xxx.ets
2271e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2272e41f4b71Sopenharmony_ci
2273e41f4b71Sopenharmony_ci  @Entry
2274e41f4b71Sopenharmony_ci  @Component
2275e41f4b71Sopenharmony_ci  struct WebComponent {
2276e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2277e41f4b71Sopenharmony_ci    @State avoidMode: WebKeyboardAvoidMode = WebKeyboardAvoidMode.RESIZE_VISUAL;
2278e41f4b71Sopenharmony_ci
2279e41f4b71Sopenharmony_ci    build() {
2280e41f4b71Sopenharmony_ci      Column() {
2281e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
2282e41f4b71Sopenharmony_ci        .keyboardAvoidMode(this.avoidMode)
2283e41f4b71Sopenharmony_ci      }
2284e41f4b71Sopenharmony_ci    }
2285e41f4b71Sopenharmony_ci  }
2286e41f4b71Sopenharmony_ci  ```
2287e41f4b71Sopenharmony_ci
2288e41f4b71Sopenharmony_ci  HTML file to be loaded:
2289e41f4b71Sopenharmony_ci  ```html
2290e41f4b71Sopenharmony_ci  <!--index.html-->
2291e41f4b71Sopenharmony_ci  <!DOCTYPE html>
2292e41f4b71Sopenharmony_ci  <html>
2293e41f4b71Sopenharmony_ci  <head>
2294e41f4b71Sopenharmony_ci    <title>Test Web Page</title>
2295e41f4b71Sopenharmony_ci  </head>
2296e41f4b71Sopenharmony_ci  <body>
2297e41f4b71Sopenharmony_ci    <input type="text" placeholder="Text">
2298e41f4b71Sopenharmony_ci  </body>
2299e41f4b71Sopenharmony_ci  </html>
2300e41f4b71Sopenharmony_ci  ```
2301e41f4b71Sopenharmony_ci
2302e41f4b71Sopenharmony_ci### editMenuOptions<sup>12+</sup>
2303e41f4b71Sopenharmony_cieditMenuOptions(editMenu: EditMenuOptions)
2304e41f4b71Sopenharmony_ci
2305e41f4b71Sopenharmony_ciSets the custom menu options of the **Web** component.
2306e41f4b71Sopenharmony_ci
2307e41f4b71Sopenharmony_ciYou can use this property to customize a text menu.
2308e41f4b71Sopenharmony_ci
2309e41f4b71Sopenharmony_ciYou can use [onCreateMenu](../apis-arkui/arkui-ts/ts-text-common.md#oncreatemenu) to modify, add, and delete menu options. If you do not want to display text menus, return an empty array.
2310e41f4b71Sopenharmony_ci
2311e41f4b71Sopenharmony_ciYou can use [onMenuItemClick](../apis-arkui/arkui-ts/ts-text-common.md#onmenuitemclick) to customize the callback for menu options. This function is triggered after a menu option is clicked and determines whether to execute the default callback based on the return value. If **true** is returned, the system callback is not executed. If **false** is returned, the system callback is executed.
2312e41f4b71Sopenharmony_ci
2313e41f4b71Sopenharmony_ciIf this API is used together with [selectionMenuOptions](#selectionmenuoptions12), **selectionMenuOptions** does not take effect.
2314e41f4b71Sopenharmony_ci
2315e41f4b71Sopenharmony_ci**Parameters**
2316e41f4b71Sopenharmony_ci| Name             | Type                             | Mandatory  | Description         |
2317e41f4b71Sopenharmony_ci| ------------------- | ------------------------------   | ------ | ------------- |
2318e41f4b71Sopenharmony_ci| editMenu | [EditMenuOptions](../apis-arkui/arkui-ts/ts-text-common.md#editmenuoptions)| Yes    | Custom menu options of the **Web** component.<br>The number of menu options, menu content size, and icon size must be the same as those of the ArkUI [\<Menu>](../apis-arkui/arkui-ts/ts-basic-components-menu.md) component.<br>The values of ([TextMenuItemId](../apis-arkui/arkui-ts/ts-text-common.md#textmenuitemid12)) supported by the **Web** component are **CUT**, **COPY**, **PASTE**, and **SELECT_ALL**.<br>**textRange** in **onMenuItemClick()** is useless in the **Web** component. The input value is **-1**.|
2319e41f4b71Sopenharmony_ci
2320e41f4b71Sopenharmony_ci**Example**
2321e41f4b71Sopenharmony_ci
2322e41f4b71Sopenharmony_ci```ts
2323e41f4b71Sopenharmony_ci// xxx.ets
2324e41f4b71Sopenharmony_ciimport { webview } from '@kit.ArkWeb';
2325e41f4b71Sopenharmony_ci
2326e41f4b71Sopenharmony_ci@Entry
2327e41f4b71Sopenharmony_ci@Component
2328e41f4b71Sopenharmony_cistruct WebComponent {
2329e41f4b71Sopenharmony_ci  controller: webview.WebviewController = new webview.WebviewController();
2330e41f4b71Sopenharmony_ci
2331e41f4b71Sopenharmony_ci  onCreateMenu(menuItems: Array<TextMenuItem>): Array<TextMenuItem> {
2332e41f4b71Sopenharmony_ci    let items = menuItems.filter((menuItem) => {
2333e41f4b71Sopenharmony_ci        // Filter the menu items as required.
2334e41f4b71Sopenharmony_ci      return (
2335e41f4b71Sopenharmony_ci        menuItem.id.equals(TextMenuItemId.CUT) ||
2336e41f4b71Sopenharmony_ci        menuItem.id.equals(TextMenuItemId.COPY) ||
2337e41f4b71Sopenharmony_ci        menuItem.id.equals((TextMenuItemId.PASTE))
2338e41f4b71Sopenharmony_ci      )
2339e41f4b71Sopenharmony_ci    });
2340e41f4b71Sopenharmony_ci    let customItem1: TextMenuItem = {
2341e41f4b71Sopenharmony_ci      content: 'customItem1',
2342e41f4b71Sopenharmony_ci      id: TextMenuItemId.of('customItem1'),
2343e41f4b71Sopenharmony_ci      icon: $r('app.media.icon')
2344e41f4b71Sopenharmony_ci    };
2345e41f4b71Sopenharmony_ci    let customItem2: TextMenuItem = {
2346e41f4b71Sopenharmony_ci      content: $r('app.string.customItem2'),
2347e41f4b71Sopenharmony_ci      id: TextMenuItemId.of('customItem2'),
2348e41f4b71Sopenharmony_ci      icon: $r('app.media.icon')
2349e41f4b71Sopenharmony_ci    };
2350e41f4b71Sopenharmony_ci    items.push(customItem1);// Add an option to the end of the option list.
2351e41f4b71Sopenharmony_ci    items.unshift(customItem2);// Add an option to the beginning of the option list.
2352e41f4b71Sopenharmony_ci
2353e41f4b71Sopenharmony_ci    return items;
2354e41f4b71Sopenharmony_ci  }
2355e41f4b71Sopenharmony_ci
2356e41f4b71Sopenharmony_ci  onMenuItemClick(menuItem: TextMenuItem, textRange: TextRange): boolean {
2357e41f4b71Sopenharmony_ci    if (menuItem.id.equals(TextMenuItemId.CUT)) {
2358e41f4b71Sopenharmony_ci      // User-defined behavior.
2359e41f4b71Sopenharmony_ci      console.log ("Intercept ID: CUT")
2360e41f4b71Sopenharmony_ci      return true; // Return true to not execute the system callback.
2361e41f4b71Sopenharmony_ci    } else if (menuItem.id.equals(TextMenuItemId.COPY)) {
2362e41f4b71Sopenharmony_ci      // User-defined behavior.
2363e41f4b71Sopenharmony_ci      console.log ("Do not intercept ID: COPY")
2364e41f4b71Sopenharmony_ci      return false; // Return false to execute the system callback.
2365e41f4b71Sopenharmony_ci    } else if (menuItem.id.equals(TextMenuItemId.of('customItem1'))) {
2366e41f4b71Sopenharmony_ci      // User-defined behavior.
2367e41f4b71Sopenharmony_ci      console.log ("Intercept ID: customItem1")
2368e41f4b71Sopenharmony_ci      return true;// Return true. There is no difference between true and false to the custom menu option, but true is recommended.
2369e41f4b71Sopenharmony_ci    } else if (menuItem.id.equals((TextMenuItemId.of($r('app.string.customItem2'))))){
2370e41f4b71Sopenharmony_ci      // User-defined behavior.
2371e41f4b71Sopenharmony_ci      console.log ("Intercept ID: app.string.customItem2")
2372e41f4b71Sopenharmony_ci      return true;
2373e41f4b71Sopenharmony_ci    }
2374e41f4b71Sopenharmony_ci    return false;// Return the default value false.
2375e41f4b71Sopenharmony_ci  }
2376e41f4b71Sopenharmony_ci
2377e41f4b71Sopenharmony_ci  @State EditMenuOptions: EditMenuOptions = { onCreateMenu: this.onCreateMenu, onMenuItemClick: this.onMenuItemClick }
2378e41f4b71Sopenharmony_ci
2379e41f4b71Sopenharmony_ci  build() {
2380e41f4b71Sopenharmony_ci    Column() {
2381e41f4b71Sopenharmony_ci      Web({ src: $rawfile("index.html"), controller: this.controller })
2382e41f4b71Sopenharmony_ci        .editMenuOptions(this.EditMenuOptions)
2383e41f4b71Sopenharmony_ci    }
2384e41f4b71Sopenharmony_ci  }
2385e41f4b71Sopenharmony_ci}
2386e41f4b71Sopenharmony_ci```
2387e41f4b71Sopenharmony_ci
2388e41f4b71Sopenharmony_ci HTML file to be loaded:
2389e41f4b71Sopenharmony_ci```html
2390e41f4b71Sopenharmony_ci<!--index.html-->
2391e41f4b71Sopenharmony_ci<!DOCTYPE html>
2392e41f4b71Sopenharmony_ci<html>
2393e41f4b71Sopenharmony_ci  <head>
2394e41f4b71Sopenharmony_ci      <title>Test Web Page</title>
2395e41f4b71Sopenharmony_ci  </head>
2396e41f4b71Sopenharmony_ci  <body>
2397e41f4b71Sopenharmony_ci    <h1>editMenuOptions Demo</h1>
2398e41f4b71Sopenharmony_ci    <span>edit menu options</span>
2399e41f4b71Sopenharmony_ci  </body>
2400e41f4b71Sopenharmony_ci</html>
2401e41f4b71Sopenharmony_ci```
2402e41f4b71Sopenharmony_ci
2403e41f4b71Sopenharmony_ci## Events
2404e41f4b71Sopenharmony_ci
2405e41f4b71Sopenharmony_ciThe following universal events are supported: [onAppear](../apis-arkui/arkui-ts/ts-universal-events-show-hide.md#onappear), [onDisAppear](../apis-arkui/arkui-ts/ts-universal-events-show-hide.md#ondisappear), [onBlur](../apis-arkui/arkui-ts/ts-universal-focus-event.md#onblur), [onFocus](../apis-arkui/arkui-ts/ts-universal-focus-event.md#onfocus), [onDragEnd](../apis-arkui/arkui-ts/ts-universal-events-drag-drop.md#ondragend), [onDragEnter](../apis-arkui/arkui-ts/ts-universal-events-drag-drop.md#ondragenter), [onDragStart](../apis-arkui/arkui-ts/ts-universal-events-drag-drop.md#ondragstart), [onDragMove](../apis-arkui/arkui-ts/ts-universal-events-drag-drop.md#ondragmove), [onDragLeave](../apis-arkui/arkui-ts/ts-universal-events-drag-drop.md#ondragleave), [onDrop](../apis-arkui/arkui-ts/ts-universal-events-drag-drop.md#ondrop), [onHover](../apis-arkui/arkui-ts/ts-universal-mouse-key.md#onhover), [onMouse](../apis-arkui/arkui-ts/ts-universal-mouse-key.md#onmouse), [onKeyEvent](../apis-arkui/arkui-ts/ts-universal-events-key.md#onkeyevent), [onTouch](../apis-arkui/arkui-ts/ts-universal-events-touch.md#ontouch), [onVisibleAreaChange](../apis-arkui/arkui-ts/ts-universal-component-visible-area-change-event.md#onvisibleareachange)
2406e41f4b71Sopenharmony_ci
2407e41f4b71Sopenharmony_ci### onAlert
2408e41f4b71Sopenharmony_ci
2409e41f4b71Sopenharmony_cionAlert(callback: Callback\<OnAlertEvent, boolean\>)
2410e41f4b71Sopenharmony_ci
2411e41f4b71Sopenharmony_ciCalled when **alert()** is invoked to display an alert dialog box on the web page.
2412e41f4b71Sopenharmony_ci
2413e41f4b71Sopenharmony_ci**Parameters**
2414e41f4b71Sopenharmony_ci
2415e41f4b71Sopenharmony_ci| Name    | Type                 | Description           |
2416e41f4b71Sopenharmony_ci| ------- | --------------------- | --------------- |
2417e41f4b71Sopenharmony_ci| callback     | Callback\<[OnAlertEvent](#onalertevent12), boolean\>                | Callback used when **alert()** is invoked to display an alert dialog box on the web page.<br>Return value: boolean<br> If the callback returns **true**, the application can use the custom dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to instruct the **Web** component to exit the current page based on the user operation. The value **false** means that the custom dialog box drawn in the function is ineffective.|
2418e41f4b71Sopenharmony_ci
2419e41f4b71Sopenharmony_ci**Example**
2420e41f4b71Sopenharmony_ci
2421e41f4b71Sopenharmony_ci  ```ts
2422e41f4b71Sopenharmony_ci  // xxx.ets
2423e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2424e41f4b71Sopenharmony_ci
2425e41f4b71Sopenharmony_ci  @Entry
2426e41f4b71Sopenharmony_ci  @Component
2427e41f4b71Sopenharmony_ci  struct WebComponent {
2428e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2429e41f4b71Sopenharmony_ci
2430e41f4b71Sopenharmony_ci    build() {
2431e41f4b71Sopenharmony_ci      Column() {
2432e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
2433e41f4b71Sopenharmony_ci          .onAlert((event) => {
2434e41f4b71Sopenharmony_ci            if (event) {
2435e41f4b71Sopenharmony_ci              console.log("event.url:" + event.url);
2436e41f4b71Sopenharmony_ci              console.log("event.message:" + event.message);
2437e41f4b71Sopenharmony_ci              AlertDialog.show({
2438e41f4b71Sopenharmony_ci                title: 'onAlert',
2439e41f4b71Sopenharmony_ci                message: 'text',
2440e41f4b71Sopenharmony_ci                primaryButton: {
2441e41f4b71Sopenharmony_ci                  value: 'cancel',
2442e41f4b71Sopenharmony_ci                  action: () => {
2443e41f4b71Sopenharmony_ci                    event.result.handleCancel();
2444e41f4b71Sopenharmony_ci                  }
2445e41f4b71Sopenharmony_ci                },
2446e41f4b71Sopenharmony_ci                secondaryButton: {
2447e41f4b71Sopenharmony_ci                  value: 'ok',
2448e41f4b71Sopenharmony_ci                  action: () => {
2449e41f4b71Sopenharmony_ci                    event.result.handleConfirm();
2450e41f4b71Sopenharmony_ci                  }
2451e41f4b71Sopenharmony_ci                },
2452e41f4b71Sopenharmony_ci                cancel: () => {
2453e41f4b71Sopenharmony_ci                  event.result.handleCancel();
2454e41f4b71Sopenharmony_ci                }
2455e41f4b71Sopenharmony_ci              })
2456e41f4b71Sopenharmony_ci            }
2457e41f4b71Sopenharmony_ci            return true;
2458e41f4b71Sopenharmony_ci          })
2459e41f4b71Sopenharmony_ci      }
2460e41f4b71Sopenharmony_ci    }
2461e41f4b71Sopenharmony_ci  }
2462e41f4b71Sopenharmony_ci  ```
2463e41f4b71Sopenharmony_ci
2464e41f4b71Sopenharmony_ci  HTML file to be loaded:
2465e41f4b71Sopenharmony_ci  ```html
2466e41f4b71Sopenharmony_ci  <!--index.html-->
2467e41f4b71Sopenharmony_ci  <!DOCTYPE html>
2468e41f4b71Sopenharmony_ci  <html>
2469e41f4b71Sopenharmony_ci  <head>
2470e41f4b71Sopenharmony_ci    <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8">
2471e41f4b71Sopenharmony_ci  </head>
2472e41f4b71Sopenharmony_ci  <body>
2473e41f4b71Sopenharmony_ci    <h1>WebView onAlert Demo</h1>
2474e41f4b71Sopenharmony_ci    <button onclick="myFunction()">Click here</button>
2475e41f4b71Sopenharmony_ci    <script>
2476e41f4b71Sopenharmony_ci      function myFunction() {
2477e41f4b71Sopenharmony_ci        alert("Hello World");
2478e41f4b71Sopenharmony_ci      }
2479e41f4b71Sopenharmony_ci    </script>
2480e41f4b71Sopenharmony_ci  </body>
2481e41f4b71Sopenharmony_ci  </html>
2482e41f4b71Sopenharmony_ci  ```
2483e41f4b71Sopenharmony_ci
2484e41f4b71Sopenharmony_ci### onBeforeUnload
2485e41f4b71Sopenharmony_ci
2486e41f4b71Sopenharmony_cionBeforeUnload(callback: Callback\<OnBeforeUnloadEvent, boolean\>)
2487e41f4b71Sopenharmony_ci
2488e41f4b71Sopenharmony_ciCalled when this page is about to exit after the user refreshes or closes the page. This API takes effect only when the page has obtained focus.
2489e41f4b71Sopenharmony_ci
2490e41f4b71Sopenharmony_ci**Parameters**
2491e41f4b71Sopenharmony_ci
2492e41f4b71Sopenharmony_ci| Name    | Type                 | Description           |
2493e41f4b71Sopenharmony_ci| ------- | --------------------- | --------------- |
2494e41f4b71Sopenharmony_ci| callback     | Callback\<[OnBeforeUnloadEvent](#onbeforeunloadevent12), boolean\>                | Callback used when this page is about to exit after the user refreshes or closes the page.<br>Return value: boolean<br> If the callback returns **true**, the application can use the custom dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to instruct the **Web** component to exit the current page based on the user operation. The value **false** means that the custom dialog box drawn in the function is ineffective.|
2495e41f4b71Sopenharmony_ci
2496e41f4b71Sopenharmony_ci**Example**
2497e41f4b71Sopenharmony_ci
2498e41f4b71Sopenharmony_ci  ```ts
2499e41f4b71Sopenharmony_ci  // xxx.ets
2500e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2501e41f4b71Sopenharmony_ci
2502e41f4b71Sopenharmony_ci  @Entry
2503e41f4b71Sopenharmony_ci  @Component
2504e41f4b71Sopenharmony_ci  struct WebComponent {
2505e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2506e41f4b71Sopenharmony_ci
2507e41f4b71Sopenharmony_ci    build() {
2508e41f4b71Sopenharmony_ci      Column() {
2509e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
2510e41f4b71Sopenharmony_ci          .onBeforeUnload((event) => {
2511e41f4b71Sopenharmony_ci            if (event) {
2512e41f4b71Sopenharmony_ci              console.log("event.url:" + event.url);
2513e41f4b71Sopenharmony_ci              console.log("event.message:" + event.message);
2514e41f4b71Sopenharmony_ci              AlertDialog.show({
2515e41f4b71Sopenharmony_ci                title: 'onBeforeUnload',
2516e41f4b71Sopenharmony_ci                message: 'text',
2517e41f4b71Sopenharmony_ci                primaryButton: {
2518e41f4b71Sopenharmony_ci                  value: 'cancel',
2519e41f4b71Sopenharmony_ci                  action: () => {
2520e41f4b71Sopenharmony_ci                    event.result.handleCancel();
2521e41f4b71Sopenharmony_ci                  }
2522e41f4b71Sopenharmony_ci                },
2523e41f4b71Sopenharmony_ci                secondaryButton: {
2524e41f4b71Sopenharmony_ci                  value: 'ok',
2525e41f4b71Sopenharmony_ci                  action: () => {
2526e41f4b71Sopenharmony_ci                    event.result.handleConfirm();
2527e41f4b71Sopenharmony_ci                  }
2528e41f4b71Sopenharmony_ci                },
2529e41f4b71Sopenharmony_ci                cancel: () => {
2530e41f4b71Sopenharmony_ci                  event.result.handleCancel();
2531e41f4b71Sopenharmony_ci                }
2532e41f4b71Sopenharmony_ci              })
2533e41f4b71Sopenharmony_ci            }
2534e41f4b71Sopenharmony_ci            return true;
2535e41f4b71Sopenharmony_ci          })
2536e41f4b71Sopenharmony_ci      }
2537e41f4b71Sopenharmony_ci    }
2538e41f4b71Sopenharmony_ci  }
2539e41f4b71Sopenharmony_ci  ```
2540e41f4b71Sopenharmony_ci
2541e41f4b71Sopenharmony_ci  HTML file to be loaded:
2542e41f4b71Sopenharmony_ci  ```html
2543e41f4b71Sopenharmony_ci  <!--index.html-->
2544e41f4b71Sopenharmony_ci  <!DOCTYPE html>
2545e41f4b71Sopenharmony_ci  <html>
2546e41f4b71Sopenharmony_ci  <head>
2547e41f4b71Sopenharmony_ci    <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8">
2548e41f4b71Sopenharmony_ci  </head>
2549e41f4b71Sopenharmony_ci  <body onbeforeunload="return myFunction()">
2550e41f4b71Sopenharmony_ci    <h1>WebView onBeforeUnload Demo</h1>
2551e41f4b71Sopenharmony_ci    <a href="https://www.example.com">Click here</a>
2552e41f4b71Sopenharmony_ci    <script>
2553e41f4b71Sopenharmony_ci      function myFunction() {
2554e41f4b71Sopenharmony_ci        return "onBeforeUnload Event";
2555e41f4b71Sopenharmony_ci      }
2556e41f4b71Sopenharmony_ci    </script>
2557e41f4b71Sopenharmony_ci  </body>
2558e41f4b71Sopenharmony_ci  </html>
2559e41f4b71Sopenharmony_ci  ```
2560e41f4b71Sopenharmony_ci
2561e41f4b71Sopenharmony_ci### onConfirm
2562e41f4b71Sopenharmony_ci
2563e41f4b71Sopenharmony_cionConfirm(callback: Callback\<OnConfirmEvent, boolean\>)
2564e41f4b71Sopenharmony_ci
2565e41f4b71Sopenharmony_ciCalled when **confirm()** is invoked by the web page.
2566e41f4b71Sopenharmony_ci
2567e41f4b71Sopenharmony_ci**Parameters**
2568e41f4b71Sopenharmony_ci
2569e41f4b71Sopenharmony_ci| Name    | Type                 | Description           |
2570e41f4b71Sopenharmony_ci| ------- | --------------------- | --------------- |
2571e41f4b71Sopenharmony_ci| callback     | Callback\<[OnConfirmEvent](#onconfirmevent12), boolean\>                | Callback used when **confirm()** is invoked by the web page.<br>Return value: boolean<br> If the callback returns **true**, the application can use the custom dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to instruct the **Web** component to exit the current page based on the user operation. The value **false** means that the custom dialog box drawn in the function is ineffective.|
2572e41f4b71Sopenharmony_ci
2573e41f4b71Sopenharmony_ci**Example**
2574e41f4b71Sopenharmony_ci
2575e41f4b71Sopenharmony_ci  ```ts
2576e41f4b71Sopenharmony_ci  // xxx.ets
2577e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2578e41f4b71Sopenharmony_ci
2579e41f4b71Sopenharmony_ci  @Entry
2580e41f4b71Sopenharmony_ci  @Component
2581e41f4b71Sopenharmony_ci  struct WebComponent {
2582e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2583e41f4b71Sopenharmony_ci
2584e41f4b71Sopenharmony_ci    build() {
2585e41f4b71Sopenharmony_ci      Column() {
2586e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
2587e41f4b71Sopenharmony_ci          .onConfirm((event) => {
2588e41f4b71Sopenharmony_ci            if (event) {
2589e41f4b71Sopenharmony_ci              console.log("event.url:" + event.url);
2590e41f4b71Sopenharmony_ci              console.log("event.message:" + event.message);
2591e41f4b71Sopenharmony_ci              AlertDialog.show({
2592e41f4b71Sopenharmony_ci                title: 'onConfirm',
2593e41f4b71Sopenharmony_ci                message: 'text',
2594e41f4b71Sopenharmony_ci                primaryButton: {
2595e41f4b71Sopenharmony_ci                  value: 'cancel',
2596e41f4b71Sopenharmony_ci                  action: () => {
2597e41f4b71Sopenharmony_ci                    event.result.handleCancel();
2598e41f4b71Sopenharmony_ci                  }
2599e41f4b71Sopenharmony_ci                },
2600e41f4b71Sopenharmony_ci                secondaryButton: {
2601e41f4b71Sopenharmony_ci                  value: 'ok',
2602e41f4b71Sopenharmony_ci                  action: () => {
2603e41f4b71Sopenharmony_ci                    event.result.handleConfirm();
2604e41f4b71Sopenharmony_ci                  }
2605e41f4b71Sopenharmony_ci                },
2606e41f4b71Sopenharmony_ci                cancel: () => {
2607e41f4b71Sopenharmony_ci                  event.result.handleCancel();
2608e41f4b71Sopenharmony_ci                }
2609e41f4b71Sopenharmony_ci              })
2610e41f4b71Sopenharmony_ci            }
2611e41f4b71Sopenharmony_ci            return true;
2612e41f4b71Sopenharmony_ci          })
2613e41f4b71Sopenharmony_ci      }
2614e41f4b71Sopenharmony_ci    }
2615e41f4b71Sopenharmony_ci  }
2616e41f4b71Sopenharmony_ci  ```
2617e41f4b71Sopenharmony_ci
2618e41f4b71Sopenharmony_ci  HTML file to be loaded:
2619e41f4b71Sopenharmony_ci  ```html
2620e41f4b71Sopenharmony_ci  <!--index.html-->
2621e41f4b71Sopenharmony_ci  <!DOCTYPE html>
2622e41f4b71Sopenharmony_ci  <html>
2623e41f4b71Sopenharmony_ci  <head>
2624e41f4b71Sopenharmony_ci    <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8">
2625e41f4b71Sopenharmony_ci  </head>
2626e41f4b71Sopenharmony_ci
2627e41f4b71Sopenharmony_ci  <body>
2628e41f4b71Sopenharmony_ci    <h1>WebView onConfirm Demo</h1>
2629e41f4b71Sopenharmony_ci    <button onclick="myFunction()">Click here</button>
2630e41f4b71Sopenharmony_ci    <p id="demo"></p>
2631e41f4b71Sopenharmony_ci    <script>
2632e41f4b71Sopenharmony_ci      function myFunction() {
2633e41f4b71Sopenharmony_ci        let x;
2634e41f4b71Sopenharmony_ci        let r = confirm("click button!");
2635e41f4b71Sopenharmony_ci        if (r == true) {
2636e41f4b71Sopenharmony_ci          x = "ok";
2637e41f4b71Sopenharmony_ci        } else {
2638e41f4b71Sopenharmony_ci          x = "cancel";
2639e41f4b71Sopenharmony_ci        }
2640e41f4b71Sopenharmony_ci        document.getElementById("demo").innerHTML = x;
2641e41f4b71Sopenharmony_ci      }
2642e41f4b71Sopenharmony_ci    </script>
2643e41f4b71Sopenharmony_ci  </body>
2644e41f4b71Sopenharmony_ci  </html>
2645e41f4b71Sopenharmony_ci  ```
2646e41f4b71Sopenharmony_ci
2647e41f4b71Sopenharmony_ci### onPrompt<sup>9+</sup>
2648e41f4b71Sopenharmony_ci
2649e41f4b71Sopenharmony_cionPrompt(callback: Callback\<OnPromptEvent, boolean\>)
2650e41f4b71Sopenharmony_ci
2651e41f4b71Sopenharmony_ciCalled when **prompt()** is invoked by the web page.
2652e41f4b71Sopenharmony_ci
2653e41f4b71Sopenharmony_ci**Parameters**
2654e41f4b71Sopenharmony_ci
2655e41f4b71Sopenharmony_ci| Name    | Type                 | Description           |
2656e41f4b71Sopenharmony_ci| ------- | --------------------- | --------------- |
2657e41f4b71Sopenharmony_ci| callback     | Callback\<[OnPromptEvent](#onpromptevent12), boolean\>                | Callback used when **prompt()** is invoked by the web page.<br>Return value: boolean<br> If the callback returns **true**, the application can use the custom dialog box (allows the confirm and cancel operations) and invoke the **JsResult** API to instruct the **Web** component to exit the current page based on the user operation. The value **false** means that the custom dialog box drawn in the function is ineffective.|
2658e41f4b71Sopenharmony_ci
2659e41f4b71Sopenharmony_ci**Example**
2660e41f4b71Sopenharmony_ci
2661e41f4b71Sopenharmony_ci  ```ts
2662e41f4b71Sopenharmony_ci  // xxx.ets
2663e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2664e41f4b71Sopenharmony_ci
2665e41f4b71Sopenharmony_ci  @Entry
2666e41f4b71Sopenharmony_ci  @Component
2667e41f4b71Sopenharmony_ci  struct WebComponent {
2668e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2669e41f4b71Sopenharmony_ci
2670e41f4b71Sopenharmony_ci    build() {
2671e41f4b71Sopenharmony_ci      Column() {
2672e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
2673e41f4b71Sopenharmony_ci          .onPrompt((event) => {
2674e41f4b71Sopenharmony_ci            if (event) {
2675e41f4b71Sopenharmony_ci              console.log("url:" + event.url);
2676e41f4b71Sopenharmony_ci              console.log("message:" + event.message);
2677e41f4b71Sopenharmony_ci              console.log("value:" + event.value);
2678e41f4b71Sopenharmony_ci              AlertDialog.show({
2679e41f4b71Sopenharmony_ci                title: 'onPrompt',
2680e41f4b71Sopenharmony_ci                message: 'text',
2681e41f4b71Sopenharmony_ci                primaryButton: {
2682e41f4b71Sopenharmony_ci                  value: 'cancel',
2683e41f4b71Sopenharmony_ci                  action: () => {
2684e41f4b71Sopenharmony_ci                    event.result.handleCancel();
2685e41f4b71Sopenharmony_ci                  }
2686e41f4b71Sopenharmony_ci                },
2687e41f4b71Sopenharmony_ci                secondaryButton: {
2688e41f4b71Sopenharmony_ci                  value: 'ok',
2689e41f4b71Sopenharmony_ci                  action: () => {
2690e41f4b71Sopenharmony_ci                    event.result.handlePromptConfirm(event.value);
2691e41f4b71Sopenharmony_ci                  }
2692e41f4b71Sopenharmony_ci                },
2693e41f4b71Sopenharmony_ci                cancel: () => {
2694e41f4b71Sopenharmony_ci                  event.result.handleCancel();
2695e41f4b71Sopenharmony_ci                }
2696e41f4b71Sopenharmony_ci              })
2697e41f4b71Sopenharmony_ci            }
2698e41f4b71Sopenharmony_ci            return true;
2699e41f4b71Sopenharmony_ci          })
2700e41f4b71Sopenharmony_ci      }
2701e41f4b71Sopenharmony_ci    }
2702e41f4b71Sopenharmony_ci  }
2703e41f4b71Sopenharmony_ci  ```
2704e41f4b71Sopenharmony_ci
2705e41f4b71Sopenharmony_ci  HTML file to be loaded:
2706e41f4b71Sopenharmony_ci  ```html
2707e41f4b71Sopenharmony_ci  <!--index.html-->
2708e41f4b71Sopenharmony_ci  <!DOCTYPE html>
2709e41f4b71Sopenharmony_ci  <html>
2710e41f4b71Sopenharmony_ci  <head>
2711e41f4b71Sopenharmony_ci    <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8">
2712e41f4b71Sopenharmony_ci  </head>
2713e41f4b71Sopenharmony_ci
2714e41f4b71Sopenharmony_ci  <body>
2715e41f4b71Sopenharmony_ci    <h1>WebView onPrompt Demo</h1>
2716e41f4b71Sopenharmony_ci    <button onclick="myFunction()">Click here</button>
2717e41f4b71Sopenharmony_ci    <p id="demo"></p>
2718e41f4b71Sopenharmony_ci    <script>
2719e41f4b71Sopenharmony_ci      function myFunction() {
2720e41f4b71Sopenharmony_ci        let message = prompt("Message info", "Hello World");
2721e41f4b71Sopenharmony_ci        if (message != null && message != "") {
2722e41f4b71Sopenharmony_ci          document.getElementById("demo").innerHTML = message;
2723e41f4b71Sopenharmony_ci        }
2724e41f4b71Sopenharmony_ci      }
2725e41f4b71Sopenharmony_ci    </script>
2726e41f4b71Sopenharmony_ci  </body>
2727e41f4b71Sopenharmony_ci  </html>
2728e41f4b71Sopenharmony_ci  ```
2729e41f4b71Sopenharmony_ci
2730e41f4b71Sopenharmony_ci### onConsole
2731e41f4b71Sopenharmony_ci
2732e41f4b71Sopenharmony_cionConsole(callback: Callback\<OnConsoleEvent, boolean\>)
2733e41f4b71Sopenharmony_ci
2734e41f4b71Sopenharmony_ciCalled to notify the host application of a JavaScript console message.
2735e41f4b71Sopenharmony_ci
2736e41f4b71Sopenharmony_ci**Parameters**
2737e41f4b71Sopenharmony_ci
2738e41f4b71Sopenharmony_ci| Name    | Type                             | Description     |
2739e41f4b71Sopenharmony_ci| ------- | --------------------------------- | --------- |
2740e41f4b71Sopenharmony_ci| callback | Callback\<[OnConsoleEvent](#onconsoleevent12), boolean\> | Called when the web page receives a JavaScript console message.<br>Return value: boolean<br> Returns **true** if the message will not be printed to the console; returns **false** otherwise.|
2741e41f4b71Sopenharmony_ci
2742e41f4b71Sopenharmony_ci**Example**
2743e41f4b71Sopenharmony_ci
2744e41f4b71Sopenharmony_ci  ```ts
2745e41f4b71Sopenharmony_ci  // xxx.ets
2746e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2747e41f4b71Sopenharmony_ci
2748e41f4b71Sopenharmony_ci  @Entry
2749e41f4b71Sopenharmony_ci  @Component
2750e41f4b71Sopenharmony_ci  struct WebComponent {
2751e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2752e41f4b71Sopenharmony_ci
2753e41f4b71Sopenharmony_ci    build() {
2754e41f4b71Sopenharmony_ci      Column() {
2755e41f4b71Sopenharmony_ci        Button('onconsole message')
2756e41f4b71Sopenharmony_ci          .onClick(() => {
2757e41f4b71Sopenharmony_ci            this.controller.runJavaScript('myFunction()');
2758e41f4b71Sopenharmony_ci          })
2759e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
2760e41f4b71Sopenharmony_ci          .onConsole((event) => {
2761e41f4b71Sopenharmony_ci            if (event) {
2762e41f4b71Sopenharmony_ci              console.log('getMessage:' + event.message.getMessage());
2763e41f4b71Sopenharmony_ci              console.log('getSourceId:' + event.message.getSourceId());
2764e41f4b71Sopenharmony_ci              console.log('getLineNumber:' + event.message.getLineNumber());
2765e41f4b71Sopenharmony_ci              console.log('getMessageLevel:' + event.message.getMessageLevel());
2766e41f4b71Sopenharmony_ci            }
2767e41f4b71Sopenharmony_ci            return false;
2768e41f4b71Sopenharmony_ci          })
2769e41f4b71Sopenharmony_ci      }
2770e41f4b71Sopenharmony_ci    }
2771e41f4b71Sopenharmony_ci  }
2772e41f4b71Sopenharmony_ci  ```
2773e41f4b71Sopenharmony_ci
2774e41f4b71Sopenharmony_ci  HTML file to be loaded:
2775e41f4b71Sopenharmony_ci  ```html
2776e41f4b71Sopenharmony_ci  <!-- index.html -->
2777e41f4b71Sopenharmony_ci  <!DOCTYPE html>
2778e41f4b71Sopenharmony_ci  <html>
2779e41f4b71Sopenharmony_ci  <body>
2780e41f4b71Sopenharmony_ci  <script>
2781e41f4b71Sopenharmony_ci      function myFunction() {
2782e41f4b71Sopenharmony_ci          console.log("onconsole printf");
2783e41f4b71Sopenharmony_ci      }
2784e41f4b71Sopenharmony_ci  </script>
2785e41f4b71Sopenharmony_ci  </body>
2786e41f4b71Sopenharmony_ci  </html>
2787e41f4b71Sopenharmony_ci  ```
2788e41f4b71Sopenharmony_ci
2789e41f4b71Sopenharmony_ci### onDownloadStart
2790e41f4b71Sopenharmony_ci
2791e41f4b71Sopenharmony_cionDownloadStart(callback: Callback\<OnDownloadStartEvent\>)
2792e41f4b71Sopenharmony_ci
2793e41f4b71Sopenharmony_ciInstructs the main application to start downloading a file.
2794e41f4b71Sopenharmony_ci
2795e41f4b71Sopenharmony_ci**Parameters**
2796e41f4b71Sopenharmony_ci
2797e41f4b71Sopenharmony_ci| Name               | Type  | Description                               |
2798e41f4b71Sopenharmony_ci| ------------------ | ------ | ----------------------------------- |
2799e41f4b71Sopenharmony_ci| callback                | Callback\<[OnDownloadStartEvent](#ondownloadstartevent12)\> | Called when the download starts.                          |
2800e41f4b71Sopenharmony_ci
2801e41f4b71Sopenharmony_ci**Example**
2802e41f4b71Sopenharmony_ci
2803e41f4b71Sopenharmony_ci  ```ts
2804e41f4b71Sopenharmony_ci  // xxx.ets
2805e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2806e41f4b71Sopenharmony_ci
2807e41f4b71Sopenharmony_ci  @Entry
2808e41f4b71Sopenharmony_ci  @Component
2809e41f4b71Sopenharmony_ci  struct WebComponent {
2810e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2811e41f4b71Sopenharmony_ci
2812e41f4b71Sopenharmony_ci    build() {
2813e41f4b71Sopenharmony_ci      Column() {
2814e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
2815e41f4b71Sopenharmony_ci          .onDownloadStart((event) => {
2816e41f4b71Sopenharmony_ci            if (event) {
2817e41f4b71Sopenharmony_ci              console.log('url:' + event.url)
2818e41f4b71Sopenharmony_ci              console.log('userAgent:' + event.userAgent)
2819e41f4b71Sopenharmony_ci              console.log('contentDisposition:' + event.contentDisposition)
2820e41f4b71Sopenharmony_ci              console.log('contentLength:' + event.contentLength)
2821e41f4b71Sopenharmony_ci              console.log('mimetype:' + event.mimetype)
2822e41f4b71Sopenharmony_ci            }
2823e41f4b71Sopenharmony_ci          })
2824e41f4b71Sopenharmony_ci      }
2825e41f4b71Sopenharmony_ci    }
2826e41f4b71Sopenharmony_ci  }
2827e41f4b71Sopenharmony_ci  ```
2828e41f4b71Sopenharmony_ci
2829e41f4b71Sopenharmony_ci### onErrorReceive
2830e41f4b71Sopenharmony_ci
2831e41f4b71Sopenharmony_cionErrorReceive(callback: Callback\<OnErrorReceiveEvent\>)
2832e41f4b71Sopenharmony_ci
2833e41f4b71Sopenharmony_ciCalled when an error occurs during web page loading. For better results, simplify the implementation logic in the callback. This API is called when there is no network connection.
2834e41f4b71Sopenharmony_ci
2835e41f4b71Sopenharmony_ci**Parameters**
2836e41f4b71Sopenharmony_ci
2837e41f4b71Sopenharmony_ci| Name    | Type                                    | Description           |
2838e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | --------------- |
2839e41f4b71Sopenharmony_ci| callback | Callback\<[OnErrorReceiveEvent](#onerrorreceiveevent12)\> | Called when an error occurs during web page loading.     |
2840e41f4b71Sopenharmony_ci
2841e41f4b71Sopenharmony_ci**Example**
2842e41f4b71Sopenharmony_ci
2843e41f4b71Sopenharmony_ci  ```ts
2844e41f4b71Sopenharmony_ci  // xxx.ets
2845e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2846e41f4b71Sopenharmony_ci
2847e41f4b71Sopenharmony_ci  @Entry
2848e41f4b71Sopenharmony_ci  @Component
2849e41f4b71Sopenharmony_ci  struct WebComponent {
2850e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2851e41f4b71Sopenharmony_ci
2852e41f4b71Sopenharmony_ci    build() {
2853e41f4b71Sopenharmony_ci      Column() {
2854e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
2855e41f4b71Sopenharmony_ci          .onErrorReceive((event) => {
2856e41f4b71Sopenharmony_ci            if (event) {
2857e41f4b71Sopenharmony_ci              console.log('getErrorInfo:' + event.error.getErrorInfo());
2858e41f4b71Sopenharmony_ci              console.log('getErrorCode:' + event.error.getErrorCode());
2859e41f4b71Sopenharmony_ci              console.log('url:' + event.request.getRequestUrl());
2860e41f4b71Sopenharmony_ci              console.log('isMainFrame:' + event.request.isMainFrame());
2861e41f4b71Sopenharmony_ci              console.log('isRedirect:' + event.request.isRedirect());
2862e41f4b71Sopenharmony_ci              console.log('isRequestGesture:' + event.request.isRequestGesture());
2863e41f4b71Sopenharmony_ci              console.log('getRequestHeader_headerKey:' + event.request.getRequestHeader().toString());
2864e41f4b71Sopenharmony_ci              let result = event.request.getRequestHeader();
2865e41f4b71Sopenharmony_ci              console.log('The request header result size is ' + result.length);
2866e41f4b71Sopenharmony_ci              for (let i of result) {
2867e41f4b71Sopenharmony_ci                console.log('The request header key is : ' + i.headerKey + ', value is : ' + i.headerValue);
2868e41f4b71Sopenharmony_ci              }
2869e41f4b71Sopenharmony_ci            }
2870e41f4b71Sopenharmony_ci          })
2871e41f4b71Sopenharmony_ci      }
2872e41f4b71Sopenharmony_ci    }
2873e41f4b71Sopenharmony_ci  }
2874e41f4b71Sopenharmony_ci  ```
2875e41f4b71Sopenharmony_ci
2876e41f4b71Sopenharmony_ci### onHttpErrorReceive
2877e41f4b71Sopenharmony_ci
2878e41f4b71Sopenharmony_cionHttpErrorReceive(callback: Callback\<OnHttpErrorReceiveEvent\>)
2879e41f4b71Sopenharmony_ci
2880e41f4b71Sopenharmony_ciCalled when an HTTP error (the response code is greater than or equal to 400) occurs during web page resource loading.
2881e41f4b71Sopenharmony_ci
2882e41f4b71Sopenharmony_ci**Parameters**
2883e41f4b71Sopenharmony_ci
2884e41f4b71Sopenharmony_ci| Name     | Type                                    | Description      |
2885e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | ---------- |
2886e41f4b71Sopenharmony_ci| callback  | Callback\<[OnHttpErrorReceiveEvent](#onhttperrorreceiveevent12)\> | Called when an HTTP error occurs during web page resource loading.|
2887e41f4b71Sopenharmony_ci
2888e41f4b71Sopenharmony_ci**Example**
2889e41f4b71Sopenharmony_ci
2890e41f4b71Sopenharmony_ci  ```ts
2891e41f4b71Sopenharmony_ci  // xxx.ets
2892e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2893e41f4b71Sopenharmony_ci
2894e41f4b71Sopenharmony_ci  @Entry
2895e41f4b71Sopenharmony_ci  @Component
2896e41f4b71Sopenharmony_ci  struct WebComponent {
2897e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2898e41f4b71Sopenharmony_ci
2899e41f4b71Sopenharmony_ci    build() {
2900e41f4b71Sopenharmony_ci      Column() {
2901e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
2902e41f4b71Sopenharmony_ci          .onHttpErrorReceive((event) => {
2903e41f4b71Sopenharmony_ci            if (event) {
2904e41f4b71Sopenharmony_ci              console.log('url:' + event.request.getRequestUrl());
2905e41f4b71Sopenharmony_ci              console.log('isMainFrame:' + event.request.isMainFrame());
2906e41f4b71Sopenharmony_ci              console.log('isRedirect:' + event.request.isRedirect());
2907e41f4b71Sopenharmony_ci              console.log('isRequestGesture:' + event.request.isRequestGesture());
2908e41f4b71Sopenharmony_ci              console.log('getResponseData:' + event.response.getResponseData());
2909e41f4b71Sopenharmony_ci              console.log('getResponseEncoding:' + event.response.getResponseEncoding());
2910e41f4b71Sopenharmony_ci              console.log('getResponseMimeType:' + event.response.getResponseMimeType());
2911e41f4b71Sopenharmony_ci              console.log('getResponseCode:' + event.response.getResponseCode());
2912e41f4b71Sopenharmony_ci              console.log('getReasonMessage:' + event.response.getReasonMessage());
2913e41f4b71Sopenharmony_ci              let result = event.request.getRequestHeader();
2914e41f4b71Sopenharmony_ci              console.log('The request header result size is ' + result.length);
2915e41f4b71Sopenharmony_ci              for (let i of result) {
2916e41f4b71Sopenharmony_ci                console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue);
2917e41f4b71Sopenharmony_ci              }
2918e41f4b71Sopenharmony_ci              let resph = event.response.getResponseHeader();
2919e41f4b71Sopenharmony_ci              console.log('The response header result size is ' + resph.length);
2920e41f4b71Sopenharmony_ci              for (let i of resph) {
2921e41f4b71Sopenharmony_ci                console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue);
2922e41f4b71Sopenharmony_ci              }
2923e41f4b71Sopenharmony_ci            }
2924e41f4b71Sopenharmony_ci          })
2925e41f4b71Sopenharmony_ci      }
2926e41f4b71Sopenharmony_ci    }
2927e41f4b71Sopenharmony_ci  }
2928e41f4b71Sopenharmony_ci  ```
2929e41f4b71Sopenharmony_ci
2930e41f4b71Sopenharmony_ci### onPageBegin
2931e41f4b71Sopenharmony_ci
2932e41f4b71Sopenharmony_cionPageBegin(callback: Callback\<OnPageBeginEvent\>)
2933e41f4b71Sopenharmony_ci
2934e41f4b71Sopenharmony_ciCalled when the web page starts to be loaded. This API is called only for the main frame content, and not for the iframe or frameset content.
2935e41f4b71Sopenharmony_ci
2936e41f4b71Sopenharmony_ciFor details about the component lifecycle, see [Lifecycle of Web Components](../../web/web-event-sequence.md).
2937e41f4b71Sopenharmony_ci
2938e41f4b71Sopenharmony_ci**Parameters**
2939e41f4b71Sopenharmony_ci
2940e41f4b71Sopenharmony_ci| Name | Type  | Description     |
2941e41f4b71Sopenharmony_ci| ---- | ------ | --------- |
2942e41f4b71Sopenharmony_ci| callback  | Callback\<[OnPageBeginEvent](#onpagebeginevent12)\> | Called when the web page starts to be loaded.|
2943e41f4b71Sopenharmony_ci
2944e41f4b71Sopenharmony_ci**Example**
2945e41f4b71Sopenharmony_ci
2946e41f4b71Sopenharmony_ci  ```ts
2947e41f4b71Sopenharmony_ci  // xxx.ets
2948e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2949e41f4b71Sopenharmony_ci
2950e41f4b71Sopenharmony_ci  @Entry
2951e41f4b71Sopenharmony_ci  @Component
2952e41f4b71Sopenharmony_ci  struct WebComponent {
2953e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2954e41f4b71Sopenharmony_ci
2955e41f4b71Sopenharmony_ci    build() {
2956e41f4b71Sopenharmony_ci      Column() {
2957e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
2958e41f4b71Sopenharmony_ci          .onPageBegin((event) => {
2959e41f4b71Sopenharmony_ci            if (event) {
2960e41f4b71Sopenharmony_ci              console.log('url:' + event.url);
2961e41f4b71Sopenharmony_ci            }
2962e41f4b71Sopenharmony_ci          })
2963e41f4b71Sopenharmony_ci      }
2964e41f4b71Sopenharmony_ci    }
2965e41f4b71Sopenharmony_ci  }
2966e41f4b71Sopenharmony_ci  ```
2967e41f4b71Sopenharmony_ci
2968e41f4b71Sopenharmony_ci### onPageEnd
2969e41f4b71Sopenharmony_ci
2970e41f4b71Sopenharmony_cionPageEnd(callback: Callback\<OnPageEndEvent\>)
2971e41f4b71Sopenharmony_ci
2972e41f4b71Sopenharmony_ciCalled when the web page loading is complete. This API takes effect only for the main frame content.
2973e41f4b71Sopenharmony_ci
2974e41f4b71Sopenharmony_ciFor details about the component lifecycle, see [Lifecycle of Web Components](../../web/web-event-sequence.md).
2975e41f4b71Sopenharmony_ci
2976e41f4b71Sopenharmony_ci**Parameters**
2977e41f4b71Sopenharmony_ci
2978e41f4b71Sopenharmony_ci| Name | Type  | Description     |
2979e41f4b71Sopenharmony_ci| ---- | ------ | --------- |
2980e41f4b71Sopenharmony_ci| callback  | Callback\<[OnPageEndEvent](#onpageendevent12)\> | Called when the web page loading is complete.|
2981e41f4b71Sopenharmony_ci
2982e41f4b71Sopenharmony_ci**Example**
2983e41f4b71Sopenharmony_ci
2984e41f4b71Sopenharmony_ci  ```ts
2985e41f4b71Sopenharmony_ci  // xxx.ets
2986e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
2987e41f4b71Sopenharmony_ci
2988e41f4b71Sopenharmony_ci  @Entry
2989e41f4b71Sopenharmony_ci  @Component
2990e41f4b71Sopenharmony_ci  struct WebComponent {
2991e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
2992e41f4b71Sopenharmony_ci
2993e41f4b71Sopenharmony_ci    build() {
2994e41f4b71Sopenharmony_ci      Column() {
2995e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
2996e41f4b71Sopenharmony_ci          .onPageEnd((event) => {
2997e41f4b71Sopenharmony_ci            if (event) {
2998e41f4b71Sopenharmony_ci              console.log('url:' + event.url);
2999e41f4b71Sopenharmony_ci            }
3000e41f4b71Sopenharmony_ci          })
3001e41f4b71Sopenharmony_ci      }
3002e41f4b71Sopenharmony_ci    }
3003e41f4b71Sopenharmony_ci  }
3004e41f4b71Sopenharmony_ci  ```
3005e41f4b71Sopenharmony_ci
3006e41f4b71Sopenharmony_ci### onProgressChange
3007e41f4b71Sopenharmony_ci
3008e41f4b71Sopenharmony_cionProgressChange(callback: Callback\<OnProgressChangeEvent\>)
3009e41f4b71Sopenharmony_ci
3010e41f4b71Sopenharmony_ciCalled when the web page loading progress changes.
3011e41f4b71Sopenharmony_ci
3012e41f4b71Sopenharmony_ci**Parameters**
3013e41f4b71Sopenharmony_ci
3014e41f4b71Sopenharmony_ci| Name        | Type  | Description                 |
3015e41f4b71Sopenharmony_ci| ----------- | ------ | --------------------- |
3016e41f4b71Sopenharmony_ci| callback | Callback\<[OnProgressChangeEvent](#onprogresschangeevent12)\> | Called when the web page loading progress changes.|
3017e41f4b71Sopenharmony_ci
3018e41f4b71Sopenharmony_ci**Example**
3019e41f4b71Sopenharmony_ci
3020e41f4b71Sopenharmony_ci  ```ts
3021e41f4b71Sopenharmony_ci  // xxx.ets
3022e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3023e41f4b71Sopenharmony_ci  @Entry
3024e41f4b71Sopenharmony_ci  @Component
3025e41f4b71Sopenharmony_ci  struct WebComponent {
3026e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3027e41f4b71Sopenharmony_ci
3028e41f4b71Sopenharmony_ci    build() {
3029e41f4b71Sopenharmony_ci      Column() {
3030e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3031e41f4b71Sopenharmony_ci          .onProgressChange((event) => {
3032e41f4b71Sopenharmony_ci            if (event) {
3033e41f4b71Sopenharmony_ci              console.log('newProgress:' + event.newProgress);
3034e41f4b71Sopenharmony_ci            }
3035e41f4b71Sopenharmony_ci          })
3036e41f4b71Sopenharmony_ci      }
3037e41f4b71Sopenharmony_ci    }
3038e41f4b71Sopenharmony_ci  }
3039e41f4b71Sopenharmony_ci  ```
3040e41f4b71Sopenharmony_ci
3041e41f4b71Sopenharmony_ci### onTitleReceive
3042e41f4b71Sopenharmony_ci
3043e41f4b71Sopenharmony_cionTitleReceive(callback: Callback\<OnTitleReceiveEvent\>)
3044e41f4b71Sopenharmony_ci
3045e41f4b71Sopenharmony_ciCalled when the document title of a web page is changed. If the <title\> element is not set for an HTML5 page, the corresponding URL is returned.
3046e41f4b71Sopenharmony_ci
3047e41f4b71Sopenharmony_ci**Parameters**
3048e41f4b71Sopenharmony_ci
3049e41f4b71Sopenharmony_ci| Name  | Type  | Description         |
3050e41f4b71Sopenharmony_ci| ----- | ------ | ------------- |
3051e41f4b71Sopenharmony_ci| callback | Callback\<[OnTitleReceiveEvent](#ontitlereceiveevent12)\> | Called when the document title of the web page is changed.|
3052e41f4b71Sopenharmony_ci
3053e41f4b71Sopenharmony_ci**Example**
3054e41f4b71Sopenharmony_ci
3055e41f4b71Sopenharmony_ci  ```ts
3056e41f4b71Sopenharmony_ci  // xxx.ets
3057e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3058e41f4b71Sopenharmony_ci
3059e41f4b71Sopenharmony_ci  @Entry
3060e41f4b71Sopenharmony_ci  @Component
3061e41f4b71Sopenharmony_ci  struct WebComponent {
3062e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3063e41f4b71Sopenharmony_ci
3064e41f4b71Sopenharmony_ci    build() {
3065e41f4b71Sopenharmony_ci      Column() {
3066e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3067e41f4b71Sopenharmony_ci          .onTitleReceive((event) => {
3068e41f4b71Sopenharmony_ci            if (event) {
3069e41f4b71Sopenharmony_ci              console.log('title:' + event.title);
3070e41f4b71Sopenharmony_ci            }
3071e41f4b71Sopenharmony_ci          })
3072e41f4b71Sopenharmony_ci      }
3073e41f4b71Sopenharmony_ci    }
3074e41f4b71Sopenharmony_ci  }
3075e41f4b71Sopenharmony_ci  ```
3076e41f4b71Sopenharmony_ci
3077e41f4b71Sopenharmony_ci### onRefreshAccessedHistory
3078e41f4b71Sopenharmony_ci
3079e41f4b71Sopenharmony_cionRefreshAccessedHistory(callback: Callback\<OnRefreshAccessedHistoryEvent\>)
3080e41f4b71Sopenharmony_ci
3081e41f4b71Sopenharmony_ciCalled when loading of the web page is complete and the access history of a web page is refreshed.
3082e41f4b71Sopenharmony_ci
3083e41f4b71Sopenharmony_ci**Parameters**
3084e41f4b71Sopenharmony_ci
3085e41f4b71Sopenharmony_ci| Name        | Type   | Description                                    |
3086e41f4b71Sopenharmony_ci| ----------- | ------- | ---------------------------------------- |
3087e41f4b71Sopenharmony_ci| callback         | Callback\<[OnRefreshAccessedHistoryEvent](#onrefreshaccessedhistoryevent12)\>  | Called when the access history of the web page is refreshed.               |
3088e41f4b71Sopenharmony_ci
3089e41f4b71Sopenharmony_ci**Example**
3090e41f4b71Sopenharmony_ci
3091e41f4b71Sopenharmony_ci  ```ts
3092e41f4b71Sopenharmony_ci  // xxx.ets
3093e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3094e41f4b71Sopenharmony_ci
3095e41f4b71Sopenharmony_ci  @Entry
3096e41f4b71Sopenharmony_ci  @Component
3097e41f4b71Sopenharmony_ci  struct WebComponent {
3098e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3099e41f4b71Sopenharmony_ci
3100e41f4b71Sopenharmony_ci    build() {
3101e41f4b71Sopenharmony_ci      Column() {
3102e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3103e41f4b71Sopenharmony_ci          .onRefreshAccessedHistory((event) => {
3104e41f4b71Sopenharmony_ci            if (event) {
3105e41f4b71Sopenharmony_ci              console.log('url:' + event.url + ' isReload:' + event.isRefreshed);
3106e41f4b71Sopenharmony_ci            }
3107e41f4b71Sopenharmony_ci          })
3108e41f4b71Sopenharmony_ci      }
3109e41f4b71Sopenharmony_ci    }
3110e41f4b71Sopenharmony_ci  }
3111e41f4b71Sopenharmony_ci  ```
3112e41f4b71Sopenharmony_ci
3113e41f4b71Sopenharmony_ci### onSslErrorReceive<sup>(deprecated)</sup>
3114e41f4b71Sopenharmony_ci
3115e41f4b71Sopenharmony_cionSslErrorReceive(callback: (event?: { handler: Function, error: object }) => void)
3116e41f4b71Sopenharmony_ci
3117e41f4b71Sopenharmony_ciCalled when an SSL error occurs during resource loading.
3118e41f4b71Sopenharmony_ci
3119e41f4b71Sopenharmony_ci> **NOTE**
3120e41f4b71Sopenharmony_ci>
3121e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [onSslErrorEventReceive<sup>9+</sup>](#onsslerroreventreceive9) instead.
3122e41f4b71Sopenharmony_ci
3123e41f4b71Sopenharmony_ci### onFileSelectorShow<sup>(deprecated)</sup>
3124e41f4b71Sopenharmony_ci
3125e41f4b71Sopenharmony_cionFileSelectorShow(callback: (event?: { callback: Function, fileSelector: object }) => void)
3126e41f4b71Sopenharmony_ci
3127e41f4b71Sopenharmony_ciCalled to process an HTML form whose input type is **file**, in response to the tapping of the **Select File** button.
3128e41f4b71Sopenharmony_ci
3129e41f4b71Sopenharmony_ci> **NOTE**
3130e41f4b71Sopenharmony_ci>
3131e41f4b71Sopenharmony_ci> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [onShowFileSelector<sup>9+</sup>](#onshowfileselector9) instead.
3132e41f4b71Sopenharmony_ci
3133e41f4b71Sopenharmony_ci### onRenderExited<sup>9+</sup>
3134e41f4b71Sopenharmony_ci
3135e41f4b71Sopenharmony_cionRenderExited(callback: Callback\<OnRenderExitedEvent\>)
3136e41f4b71Sopenharmony_ci
3137e41f4b71Sopenharmony_ciCalled when the rendering process exits abnormally.
3138e41f4b71Sopenharmony_ci
3139e41f4b71Sopenharmony_ciA rendering process may shared by multiple Web components. Each affected Web component triggers this callback.
3140e41f4b71Sopenharmony_ci
3141e41f4b71Sopenharmony_ciYou call the bound **webviewContoller** APIs to restore the web page when this callback is triggered. For example, [refresh](js-apis-webview.md#refresh) and [loadUrl](js-apis-webview.md#loadurl).
3142e41f4b71Sopenharmony_ci
3143e41f4b71Sopenharmony_ciFor details about the component lifecycle, see [Lifecycle of Web Components](../../web/web-event-sequence.md).
3144e41f4b71Sopenharmony_ci
3145e41f4b71Sopenharmony_ci**Parameters**
3146e41f4b71Sopenharmony_ci
3147e41f4b71Sopenharmony_ci| Name             | Type                                    | Description            |
3148e41f4b71Sopenharmony_ci| ---------------- | ---------------------------------------- | ---------------- |
3149e41f4b71Sopenharmony_ci| callback | Callback\<[OnRenderExitedEvent](#onrenderexitedevent12)\> | Called when the rendering process exits abnormally.|
3150e41f4b71Sopenharmony_ci
3151e41f4b71Sopenharmony_ci**Example**
3152e41f4b71Sopenharmony_ci
3153e41f4b71Sopenharmony_ci  ```ts
3154e41f4b71Sopenharmony_ci  // xxx.ets
3155e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3156e41f4b71Sopenharmony_ci
3157e41f4b71Sopenharmony_ci  @Entry
3158e41f4b71Sopenharmony_ci  @Component
3159e41f4b71Sopenharmony_ci  struct WebComponent {
3160e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3161e41f4b71Sopenharmony_ci
3162e41f4b71Sopenharmony_ci    build() {
3163e41f4b71Sopenharmony_ci      Column() {
3164e41f4b71Sopenharmony_ci        Web({ src: 'chrome://crash/', controller: this.controller })
3165e41f4b71Sopenharmony_ci          .onRenderExited((event) => {
3166e41f4b71Sopenharmony_ci            if (event) {
3167e41f4b71Sopenharmony_ci              console.log('reason:' + event.renderExitReason);
3168e41f4b71Sopenharmony_ci            }
3169e41f4b71Sopenharmony_ci          })
3170e41f4b71Sopenharmony_ci      }
3171e41f4b71Sopenharmony_ci    }
3172e41f4b71Sopenharmony_ci  }
3173e41f4b71Sopenharmony_ci  ```
3174e41f4b71Sopenharmony_ci### onRenderProcessNotResponding<sup>12+</sup>
3175e41f4b71Sopenharmony_ci
3176e41f4b71Sopenharmony_cionRenderProcessNotResponding(callback: OnRenderProcessNotRespondingCallback)
3177e41f4b71Sopenharmony_ci
3178e41f4b71Sopenharmony_ciCalled when the rendering process does not respond. If the **Web** component cannot process the input event or navigate to a new URL within a proper time range, the web page process is considered unresponsive and the callback is triggered.
3179e41f4b71Sopenharmony_ci
3180e41f4b71Sopenharmony_ciIf the web page process does not respond, this callback may be triggered until the web page process responds again. In this case, [onRenderProcessResponding](#onrenderprocessresponding12) is triggered.
3181e41f4b71Sopenharmony_ci
3182e41f4b71Sopenharmony_ciYou can terminate the associated rendering process through [terminateRenderProcess](js-apis-webview.md#terminaterenderprocess12), which may affect other Web components in the same rendering process.
3183e41f4b71Sopenharmony_ci
3184e41f4b71Sopenharmony_ci**Parameters**
3185e41f4b71Sopenharmony_ci
3186e41f4b71Sopenharmony_ci| Name  | Type                                                        | Description                                  |
3187e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | -------------------------------------- |
3188e41f4b71Sopenharmony_ci| callback | [OnRenderProcessNotRespondingCallback](#onrenderprocessnotrespondingcallback12) | Callback triggered when the rendering process does not respond.|
3189e41f4b71Sopenharmony_ci
3190e41f4b71Sopenharmony_ci**Example**
3191e41f4b71Sopenharmony_ci
3192e41f4b71Sopenharmony_ci  ```ts
3193e41f4b71Sopenharmony_ci  // xxx.ets
3194e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3195e41f4b71Sopenharmony_ci
3196e41f4b71Sopenharmony_ci  @Entry
3197e41f4b71Sopenharmony_ci  @Component
3198e41f4b71Sopenharmony_ci  struct WebComponent {
3199e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3200e41f4b71Sopenharmony_ci
3201e41f4b71Sopenharmony_ci    build() {
3202e41f4b71Sopenharmony_ci      Column() {
3203e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3204e41f4b71Sopenharmony_ci          .onRenderProcessNotResponding((data) => {
3205e41f4b71Sopenharmony_ci            console.log("onRenderProcessNotResponding: [jsStack]= " + data.jsStack +
3206e41f4b71Sopenharmony_ci              ", [process]=" + data.pid + ", [reason]=" + data.reason);
3207e41f4b71Sopenharmony_ci          })
3208e41f4b71Sopenharmony_ci      }
3209e41f4b71Sopenharmony_ci    }
3210e41f4b71Sopenharmony_ci  }
3211e41f4b71Sopenharmony_ci  ```
3212e41f4b71Sopenharmony_ci
3213e41f4b71Sopenharmony_ci### onRenderProcessResponding<sup>12+</sup>
3214e41f4b71Sopenharmony_ci
3215e41f4b71Sopenharmony_cionRenderProcessResponding(callback: OnRenderProcessRespondingCallback)
3216e41f4b71Sopenharmony_ci
3217e41f4b71Sopenharmony_ciCalled when the rendering process transitions back to a normal operating state from an unresponsive state. This callback indicates that the web page was not actually frozen.
3218e41f4b71Sopenharmony_ci
3219e41f4b71Sopenharmony_ci**Parameters**
3220e41f4b71Sopenharmony_ci
3221e41f4b71Sopenharmony_ci| Name  | Type                                                        | Description                                  |
3222e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | -------------------------------------- |
3223e41f4b71Sopenharmony_ci| callback | [OnRenderProcessRespondingCallback](#onrenderprocessrespondingcallback12) | Callback triggered when the rendering process transitions back to a normal operating state from an unresponsive state.|
3224e41f4b71Sopenharmony_ci
3225e41f4b71Sopenharmony_ci**Example**
3226e41f4b71Sopenharmony_ci
3227e41f4b71Sopenharmony_ci  ```ts
3228e41f4b71Sopenharmony_ci  // xxx.ets
3229e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3230e41f4b71Sopenharmony_ci
3231e41f4b71Sopenharmony_ci  @Entry
3232e41f4b71Sopenharmony_ci  @Component
3233e41f4b71Sopenharmony_ci  struct WebComponent {
3234e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3235e41f4b71Sopenharmony_ci
3236e41f4b71Sopenharmony_ci    build() {
3237e41f4b71Sopenharmony_ci      Column() {
3238e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3239e41f4b71Sopenharmony_ci          .onRenderProcessResponding(() => {
3240e41f4b71Sopenharmony_ci            console.log("onRenderProcessResponding again");
3241e41f4b71Sopenharmony_ci          })
3242e41f4b71Sopenharmony_ci      }
3243e41f4b71Sopenharmony_ci    }
3244e41f4b71Sopenharmony_ci  }
3245e41f4b71Sopenharmony_ci  ```
3246e41f4b71Sopenharmony_ci
3247e41f4b71Sopenharmony_ci### onShowFileSelector<sup>9+</sup>
3248e41f4b71Sopenharmony_ci
3249e41f4b71Sopenharmony_cionShowFileSelector(callback: Callback\<OnShowFileSelectorEvent, boolean\>)
3250e41f4b71Sopenharmony_ci
3251e41f4b71Sopenharmony_ciCalled to process an HTML form whose input type is **file**. If this function is not called or returns **false**, the **Web** component provides the default **Select File** handling UI. If it returns **true**, the application can customize the response behavior for **Select File**.
3252e41f4b71Sopenharmony_ci
3253e41f4b71Sopenharmony_ci**Parameters**
3254e41f4b71Sopenharmony_ci
3255e41f4b71Sopenharmony_ci| Name         | Type                                    | Description             |
3256e41f4b71Sopenharmony_ci| ------------ | ---------------------------------------- | ----------------- |
3257e41f4b71Sopenharmony_ci| callback       | Callback\<[OnShowFileSelectorEvent](#onshowfileselectorevent12), boolean\> | File selection result to be sent to the **Web** component.<br>Return value: boolean<br> The value **true** means that you can invoke the system-provided popup capability. The value **false** means that the custom dialog box drawn in the function is ineffective.|
3258e41f4b71Sopenharmony_ci
3259e41f4b71Sopenharmony_ci**Example**
3260e41f4b71Sopenharmony_ci
3261e41f4b71Sopenharmony_ci1. Start the file selector.
3262e41f4b71Sopenharmony_ci
3263e41f4b71Sopenharmony_ci   ```ts
3264e41f4b71Sopenharmony_ci   // xxx.ets
3265e41f4b71Sopenharmony_ci   import { webview } from '@kit.ArkWeb';
3266e41f4b71Sopenharmony_ci   import { picker } from '@kit.CoreFileKit';
3267e41f4b71Sopenharmony_ci   import { BusinessError } from '@kit.BasicServicesKit';
3268e41f4b71Sopenharmony_ci
3269e41f4b71Sopenharmony_ci   @Entry
3270e41f4b71Sopenharmony_ci   @Component
3271e41f4b71Sopenharmony_ci   struct WebComponent {
3272e41f4b71Sopenharmony_ci     controller: webview.WebviewController = new webview.WebviewController()
3273e41f4b71Sopenharmony_ci
3274e41f4b71Sopenharmony_ci     build() {
3275e41f4b71Sopenharmony_ci       Column() {
3276e41f4b71Sopenharmony_ci         Web({ src: $rawfile('index.html'), controller: this.controller })
3277e41f4b71Sopenharmony_ci           .onShowFileSelector((event) => {
3278e41f4b71Sopenharmony_ci             console.log('MyFileUploader onShowFileSelector invoked')
3279e41f4b71Sopenharmony_ci             const documentSelectOptions = new picker.DocumentSelectOptions();
3280e41f4b71Sopenharmony_ci             let uri: string | null = null;
3281e41f4b71Sopenharmony_ci             const documentViewPicker = new picker.DocumentViewPicker();
3282e41f4b71Sopenharmony_ci             documentViewPicker.select(documentSelectOptions).then((documentSelectResult) => {
3283e41f4b71Sopenharmony_ci               uri = documentSelectResult[0];
3284e41f4b71Sopenharmony_ci               console.info('documentViewPicker.select to file succeed and uri is:' + uri);
3285e41f4b71Sopenharmony_ci               if (event) {
3286e41f4b71Sopenharmony_ci                 event.result.handleFileList([uri]);
3287e41f4b71Sopenharmony_ci               }
3288e41f4b71Sopenharmony_ci             }).catch((err: BusinessError) => {
3289e41f4b71Sopenharmony_ci               console.error(`Invoke documentViewPicker.select failed, code is ${err.code},  message is ${err.message}`);
3290e41f4b71Sopenharmony_ci             })
3291e41f4b71Sopenharmony_ci             return true;
3292e41f4b71Sopenharmony_ci           })
3293e41f4b71Sopenharmony_ci       }
3294e41f4b71Sopenharmony_ci     }
3295e41f4b71Sopenharmony_ci   }
3296e41f4b71Sopenharmony_ci   ```
3297e41f4b71Sopenharmony_ci
3298e41f4b71Sopenharmony_ci2. Start the photo selector.
3299e41f4b71Sopenharmony_ci
3300e41f4b71Sopenharmony_ci   ```ts
3301e41f4b71Sopenharmony_ci   // xxx.ets
3302e41f4b71Sopenharmony_ci   import { webview } from '@kit.ArkWeb';
3303e41f4b71Sopenharmony_ci   import { picker } from '@kit.CoreFileKit';
3304e41f4b71Sopenharmony_ci   import { photoAccessHelper } from '@kit.MediaLibraryKit';
3305e41f4b71Sopenharmony_ci
3306e41f4b71Sopenharmony_ci   @Entry
3307e41f4b71Sopenharmony_ci   @Component
3308e41f4b71Sopenharmony_ci   export struct WebComponent {
3309e41f4b71Sopenharmony_ci     controller: webview.WebviewController = new webview.WebviewController()
3310e41f4b71Sopenharmony_ci
3311e41f4b71Sopenharmony_ci     async selectFile(result: FileSelectorResult): Promise<void> {
3312e41f4b71Sopenharmony_ci       let photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
3313e41f4b71Sopenharmony_ci       let photoPicker = new photoAccessHelper.PhotoViewPicker();
3314e41f4b71Sopenharmony_ci       // Set the MIME file type to IMAGE.
3315e41f4b71Sopenharmony_ci       photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE;
3316e41f4b71Sopenharmony_ci       // Set the maximum number of media files that can be selected.
3317e41f4b71Sopenharmony_ci       photoSelectOptions.maxSelectNumber = 5;
3318e41f4b71Sopenharmony_ci       let chooseFile: picker.PhotoSelectResult = await photoPicker.select(photoSelectOptions);
3319e41f4b71Sopenharmony_ci       // Obtain the list of selected files.
3320e41f4b71Sopenharmony_ci       result.handleFileList(chooseFile.photoUris);
3321e41f4b71Sopenharmony_ci     }
3322e41f4b71Sopenharmony_ci
3323e41f4b71Sopenharmony_ci     build() {
3324e41f4b71Sopenharmony_ci       Column() {
3325e41f4b71Sopenharmony_ci         Web({ src: $rawfile('index.html'), controller: this.controller })
3326e41f4b71Sopenharmony_ci           .onShowFileSelector((event) => {
3327e41f4b71Sopenharmony_ci             if (event) {
3328e41f4b71Sopenharmony_ci               this.selectFile(event.result);
3329e41f4b71Sopenharmony_ci             }
3330e41f4b71Sopenharmony_ci             return true;
3331e41f4b71Sopenharmony_ci           })
3332e41f4b71Sopenharmony_ci       }
3333e41f4b71Sopenharmony_ci     }
3334e41f4b71Sopenharmony_ci   }
3335e41f4b71Sopenharmony_ci   ```
3336e41f4b71Sopenharmony_ci
3337e41f4b71Sopenharmony_ci   HTML file to be loaded:
3338e41f4b71Sopenharmony_ci   ```html
3339e41f4b71Sopenharmony_ci   <!DOCTYPE html>
3340e41f4b71Sopenharmony_ci   <html>
3341e41f4b71Sopenharmony_ci   <head>
3342e41f4b71Sopenharmony_ci     <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8">
3343e41f4b71Sopenharmony_ci   </head>
3344e41f4b71Sopenharmony_ci   <body>
3345e41f4b71Sopenharmony_ci     <form id="upload-form" enctype="multipart/form-data">
3346e41f4b71Sopenharmony_ci       <input type="file" id="upload" name="upload"/>
3347e41f4b71Sopenharmony_ci       </form>
3348e41f4b71Sopenharmony_ci   </body>
3349e41f4b71Sopenharmony_ci   </html>
3350e41f4b71Sopenharmony_ci   ```
3351e41f4b71Sopenharmony_ci
3352e41f4b71Sopenharmony_ci### onResourceLoad<sup>9+</sup>
3353e41f4b71Sopenharmony_ci
3354e41f4b71Sopenharmony_cionResourceLoad(callback: Callback\<OnResourceLoadEvent\>)
3355e41f4b71Sopenharmony_ci
3356e41f4b71Sopenharmony_ciCalled to notify the **Web** component of the URL of the loaded resource file.
3357e41f4b71Sopenharmony_ci
3358e41f4b71Sopenharmony_ci**Parameters**
3359e41f4b71Sopenharmony_ci
3360e41f4b71Sopenharmony_ci| Name | Type  | Description          |
3361e41f4b71Sopenharmony_ci| ---- | ------ | -------------- |
3362e41f4b71Sopenharmony_ci| callback  | Callback\<[OnResourceLoadEvent](#onresourceloadevent12)\> | Callback invoked when a URL is loaded.|
3363e41f4b71Sopenharmony_ci
3364e41f4b71Sopenharmony_ci**Example**
3365e41f4b71Sopenharmony_ci
3366e41f4b71Sopenharmony_ci  ```ts
3367e41f4b71Sopenharmony_ci  // xxx.ets
3368e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3369e41f4b71Sopenharmony_ci
3370e41f4b71Sopenharmony_ci  @Entry
3371e41f4b71Sopenharmony_ci  @Component
3372e41f4b71Sopenharmony_ci  struct WebComponent {
3373e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3374e41f4b71Sopenharmony_ci
3375e41f4b71Sopenharmony_ci    build() {
3376e41f4b71Sopenharmony_ci      Column() {
3377e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3378e41f4b71Sopenharmony_ci          .onResourceLoad((event) => {
3379e41f4b71Sopenharmony_ci            console.log('onResourceLoad: ' + event.url);
3380e41f4b71Sopenharmony_ci          })
3381e41f4b71Sopenharmony_ci      }
3382e41f4b71Sopenharmony_ci    }
3383e41f4b71Sopenharmony_ci  }
3384e41f4b71Sopenharmony_ci  ```
3385e41f4b71Sopenharmony_ci
3386e41f4b71Sopenharmony_ci### onScaleChange<sup>9+</sup>
3387e41f4b71Sopenharmony_ci
3388e41f4b71Sopenharmony_cionScaleChange(callback: Callback\<OnScaleChangeEvent\>)
3389e41f4b71Sopenharmony_ci
3390e41f4b71Sopenharmony_ciCalled when the display ratio of this page changes.
3391e41f4b71Sopenharmony_ci
3392e41f4b71Sopenharmony_ci**Parameters**
3393e41f4b71Sopenharmony_ci
3394e41f4b71Sopenharmony_ci| Name     | Type  | Description        |
3395e41f4b71Sopenharmony_ci| -------- | ------ | ------------ |
3396e41f4b71Sopenharmony_ci| callback | Callback\<[OnScaleChangeEvent](#onscalechangeevent12)\> | Callback invoked when the display ratio of the page changes.|
3397e41f4b71Sopenharmony_ci
3398e41f4b71Sopenharmony_ci**Example**
3399e41f4b71Sopenharmony_ci
3400e41f4b71Sopenharmony_ci  ```ts
3401e41f4b71Sopenharmony_ci  // xxx.ets
3402e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3403e41f4b71Sopenharmony_ci
3404e41f4b71Sopenharmony_ci  @Entry
3405e41f4b71Sopenharmony_ci  @Component
3406e41f4b71Sopenharmony_ci  struct WebComponent {
3407e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3408e41f4b71Sopenharmony_ci
3409e41f4b71Sopenharmony_ci    build() {
3410e41f4b71Sopenharmony_ci      Column() {
3411e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3412e41f4b71Sopenharmony_ci          .onScaleChange((event) => {
3413e41f4b71Sopenharmony_ci            console.log('onScaleChange changed from ' + event.oldScale + ' to ' + event.newScale);
3414e41f4b71Sopenharmony_ci          })
3415e41f4b71Sopenharmony_ci      }
3416e41f4b71Sopenharmony_ci    }
3417e41f4b71Sopenharmony_ci  }
3418e41f4b71Sopenharmony_ci  ```
3419e41f4b71Sopenharmony_ci
3420e41f4b71Sopenharmony_ci### onUrlLoadIntercept<sup>(deprecated)</sup>
3421e41f4b71Sopenharmony_ci
3422e41f4b71Sopenharmony_cionUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => boolean)
3423e41f4b71Sopenharmony_ci
3424e41f4b71Sopenharmony_ciCalled when the **Web** component is about to access a URL. This API is used to determine whether to block the access, which is allowed by default.
3425e41f4b71Sopenharmony_ciThis API is deprecated since API version 10. You are advised to use [onLoadIntercept<sup>10+</sup>](#onloadintercept10) instead.
3426e41f4b71Sopenharmony_ci
3427e41f4b71Sopenharmony_ci**Parameters**
3428e41f4b71Sopenharmony_ci
3429e41f4b71Sopenharmony_ci| Name | Type                                    | Description     |
3430e41f4b71Sopenharmony_ci| ---- | ---------------------------------------- | --------- |
3431e41f4b71Sopenharmony_ci| data | string \| [WebResourceRequest](#webresourcerequest) | URL information.|
3432e41f4b71Sopenharmony_ci
3433e41f4b71Sopenharmony_ci**Return value**
3434e41f4b71Sopenharmony_ci
3435e41f4b71Sopenharmony_ci| Type     | Description                      |
3436e41f4b71Sopenharmony_ci| ------- | ------------------------ |
3437e41f4b71Sopenharmony_ci| boolean | Returns **true** if the access is blocked; returns **false** otherwise.|
3438e41f4b71Sopenharmony_ci
3439e41f4b71Sopenharmony_ci**Example**
3440e41f4b71Sopenharmony_ci
3441e41f4b71Sopenharmony_ci  ```ts
3442e41f4b71Sopenharmony_ci  // xxx.ets
3443e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3444e41f4b71Sopenharmony_ci
3445e41f4b71Sopenharmony_ci  @Entry
3446e41f4b71Sopenharmony_ci  @Component
3447e41f4b71Sopenharmony_ci  struct WebComponent {
3448e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3449e41f4b71Sopenharmony_ci
3450e41f4b71Sopenharmony_ci    build() {
3451e41f4b71Sopenharmony_ci      Column() {
3452e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3453e41f4b71Sopenharmony_ci          .onUrlLoadIntercept((event) => {
3454e41f4b71Sopenharmony_ci            if (event) {
3455e41f4b71Sopenharmony_ci              console.log('onUrlLoadIntercept ' + event.data.toString());
3456e41f4b71Sopenharmony_ci            }
3457e41f4b71Sopenharmony_ci            return true
3458e41f4b71Sopenharmony_ci          })
3459e41f4b71Sopenharmony_ci      }
3460e41f4b71Sopenharmony_ci    }
3461e41f4b71Sopenharmony_ci  }
3462e41f4b71Sopenharmony_ci  ```
3463e41f4b71Sopenharmony_ci
3464e41f4b71Sopenharmony_ci### onInterceptRequest<sup>9+</sup>
3465e41f4b71Sopenharmony_ci
3466e41f4b71Sopenharmony_cionInterceptRequest(callback: Callback<OnInterceptRequestEvent, WebResourceResponse>)
3467e41f4b71Sopenharmony_ci
3468e41f4b71Sopenharmony_ciCalled when the **Web** component is about to access a URL. This API is used to block the URL and return the response data.
3469e41f4b71Sopenharmony_ci
3470e41f4b71Sopenharmony_ci**Parameters**
3471e41f4b71Sopenharmony_ci
3472e41f4b71Sopenharmony_ci| Name    | Type                                    | Description       |
3473e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | ----------- |
3474e41f4b71Sopenharmony_ci| callback | Callback\<[OnInterceptRequestEvent](#oninterceptrequestevent12)\> | Callback invoked when the **Web** component is about to load a URL.<br>The return value is [WebResourceResponse](#webresourceresponse). If response data is returned, the data is loaded based on the response data. If no response data is returned, null is returned, indicating that the data is loaded in the original mode.|
3475e41f4b71Sopenharmony_ci
3476e41f4b71Sopenharmony_ci**Example**
3477e41f4b71Sopenharmony_ci
3478e41f4b71Sopenharmony_ci  ```ts
3479e41f4b71Sopenharmony_ci  // xxx.ets
3480e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3481e41f4b71Sopenharmony_ci
3482e41f4b71Sopenharmony_ci  @Entry
3483e41f4b71Sopenharmony_ci  @Component
3484e41f4b71Sopenharmony_ci  struct WebComponent {
3485e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3486e41f4b71Sopenharmony_ci    responseWeb: WebResourceResponse = new WebResourceResponse();
3487e41f4b71Sopenharmony_ci    heads: Header[] = new Array();
3488e41f4b71Sopenharmony_ci    @State webData: string = "<!DOCTYPE html>\n" +
3489e41f4b71Sopenharmony_ci      "<html>\n" +
3490e41f4b71Sopenharmony_ci      "<head>\n" +
3491e41f4b71Sopenharmony_ci      "<title>intercept test</title>\n" +
3492e41f4b71Sopenharmony_ci      "</head>\n" +
3493e41f4b71Sopenharmony_ci      "<body>\n" +
3494e41f4b71Sopenharmony_ci      "<h1>intercept test</h1>\n" +
3495e41f4b71Sopenharmony_ci      "</body>\n" +
3496e41f4b71Sopenharmony_ci      "</html>";
3497e41f4b71Sopenharmony_ci
3498e41f4b71Sopenharmony_ci    build() {
3499e41f4b71Sopenharmony_ci      Column() {
3500e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3501e41f4b71Sopenharmony_ci          .onInterceptRequest((event) => {
3502e41f4b71Sopenharmony_ci            if (event) {
3503e41f4b71Sopenharmony_ci              console.log('url:' + event.request.getRequestUrl());
3504e41f4b71Sopenharmony_ci            }
3505e41f4b71Sopenharmony_ci            let head1: Header = {
3506e41f4b71Sopenharmony_ci              headerKey: "Connection",
3507e41f4b71Sopenharmony_ci              headerValue: "keep-alive"
3508e41f4b71Sopenharmony_ci            }
3509e41f4b71Sopenharmony_ci            let head2: Header = {
3510e41f4b71Sopenharmony_ci              headerKey: "Cache-Control",
3511e41f4b71Sopenharmony_ci              headerValue: "no-cache"
3512e41f4b71Sopenharmony_ci            }
3513e41f4b71Sopenharmony_ci            let length = this.heads.push(head1);
3514e41f4b71Sopenharmony_ci            length = this.heads.push(head2);
3515e41f4b71Sopenharmony_ci            const promise: Promise<String> = new Promise((resolve: Function, reject: Function) => {
3516e41f4b71Sopenharmony_ci              this.responseWeb.setResponseHeader(this.heads);
3517e41f4b71Sopenharmony_ci              this.responseWeb.setResponseData(this.webData);
3518e41f4b71Sopenharmony_ci              this.responseWeb.setResponseEncoding('utf-8');
3519e41f4b71Sopenharmony_ci              this.responseWeb.setResponseMimeType('text/html');
3520e41f4b71Sopenharmony_ci              this.responseWeb.setResponseCode(200);
3521e41f4b71Sopenharmony_ci              this.responseWeb.setReasonMessage('OK');
3522e41f4b71Sopenharmony_ci              resolve("success");
3523e41f4b71Sopenharmony_ci            })
3524e41f4b71Sopenharmony_ci            promise.then(() => {
3525e41f4b71Sopenharmony_ci              console.log("prepare response ready");
3526e41f4b71Sopenharmony_ci              this.responseWeb.setResponseIsReady(true);
3527e41f4b71Sopenharmony_ci            })
3528e41f4b71Sopenharmony_ci            this.responseWeb.setResponseIsReady(false);
3529e41f4b71Sopenharmony_ci            return this.responseWeb;
3530e41f4b71Sopenharmony_ci          })
3531e41f4b71Sopenharmony_ci      }
3532e41f4b71Sopenharmony_ci    }
3533e41f4b71Sopenharmony_ci  }
3534e41f4b71Sopenharmony_ci  ```
3535e41f4b71Sopenharmony_ci
3536e41f4b71Sopenharmony_ci### onHttpAuthRequest<sup>9+</sup>
3537e41f4b71Sopenharmony_ci
3538e41f4b71Sopenharmony_cionHttpAuthRequest(callback: Callback\<OnHttpAuthRequestEvent, boolean\>)
3539e41f4b71Sopenharmony_ci
3540e41f4b71Sopenharmony_ciCalled when an HTTP authentication request is received.
3541e41f4b71Sopenharmony_ci
3542e41f4b71Sopenharmony_ci**Parameters**
3543e41f4b71Sopenharmony_ci
3544e41f4b71Sopenharmony_ci| Name    | Type                                | Description            |
3545e41f4b71Sopenharmony_ci| ------- | ------------------------------------ | ---------------- |
3546e41f4b71Sopenharmony_ci| callback | Callback\<[OnHttpAuthRequestEvent](#onhttpauthrequestevent12), boolean\> | Callback invoked when the browser requires user credentials.<br>Return value: boolean<br> Returns **true** if the authentication is successful; returns **false** otherwise.  |
3547e41f4b71Sopenharmony_ci
3548e41f4b71Sopenharmony_ci**Example**
3549e41f4b71Sopenharmony_ci
3550e41f4b71Sopenharmony_ci  ```ts
3551e41f4b71Sopenharmony_ci  // xxx.ets
3552e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3553e41f4b71Sopenharmony_ci
3554e41f4b71Sopenharmony_ci  @Entry
3555e41f4b71Sopenharmony_ci  @Component
3556e41f4b71Sopenharmony_ci  struct WebComponent {
3557e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3558e41f4b71Sopenharmony_ci    httpAuth: boolean = false;
3559e41f4b71Sopenharmony_ci
3560e41f4b71Sopenharmony_ci    build() {
3561e41f4b71Sopenharmony_ci      Column() {
3562e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3563e41f4b71Sopenharmony_ci          .onHttpAuthRequest((event) => {
3564e41f4b71Sopenharmony_ci            if (event) {
3565e41f4b71Sopenharmony_ci              AlertDialog.show({
3566e41f4b71Sopenharmony_ci                title: 'onHttpAuthRequest',
3567e41f4b71Sopenharmony_ci                message: 'text',
3568e41f4b71Sopenharmony_ci                primaryButton: {
3569e41f4b71Sopenharmony_ci                  value: 'cancel',
3570e41f4b71Sopenharmony_ci                  action: () => {
3571e41f4b71Sopenharmony_ci                    event.handler.cancel();
3572e41f4b71Sopenharmony_ci                  }
3573e41f4b71Sopenharmony_ci                },
3574e41f4b71Sopenharmony_ci                secondaryButton: {
3575e41f4b71Sopenharmony_ci                  value: 'ok',
3576e41f4b71Sopenharmony_ci                  action: () => {
3577e41f4b71Sopenharmony_ci                    this.httpAuth = event.handler.isHttpAuthInfoSaved();
3578e41f4b71Sopenharmony_ci                    if (this.httpAuth == false) {
3579e41f4b71Sopenharmony_ci                      webview.WebDataBase.saveHttpAuthCredentials(
3580e41f4b71Sopenharmony_ci                        event.host,
3581e41f4b71Sopenharmony_ci                        event.realm,
3582e41f4b71Sopenharmony_ci                        "2222",
3583e41f4b71Sopenharmony_ci                        "2222"
3584e41f4b71Sopenharmony_ci                      )
3585e41f4b71Sopenharmony_ci                      event.handler.cancel();
3586e41f4b71Sopenharmony_ci                    }
3587e41f4b71Sopenharmony_ci                  }
3588e41f4b71Sopenharmony_ci                },
3589e41f4b71Sopenharmony_ci                cancel: () => {
3590e41f4b71Sopenharmony_ci                  event.handler.cancel();
3591e41f4b71Sopenharmony_ci                }
3592e41f4b71Sopenharmony_ci              })
3593e41f4b71Sopenharmony_ci            }
3594e41f4b71Sopenharmony_ci            return true;
3595e41f4b71Sopenharmony_ci          })
3596e41f4b71Sopenharmony_ci      }
3597e41f4b71Sopenharmony_ci    }
3598e41f4b71Sopenharmony_ci  }
3599e41f4b71Sopenharmony_ci  ```
3600e41f4b71Sopenharmony_ci### onSslErrorEventReceive<sup>9+</sup>
3601e41f4b71Sopenharmony_ci
3602e41f4b71Sopenharmony_cionSslErrorEventReceive(callback: Callback\<OnSslErrorEventReceiveEvent\>)
3603e41f4b71Sopenharmony_ci
3604e41f4b71Sopenharmony_ciCalled to notify users when an SSL error occurs with a request for the main frame.
3605e41f4b71Sopenharmony_ciTo include errors with requests for subframes, use the [OnSslErrorEvent](#onsslerrorevent12) API.
3606e41f4b71Sopenharmony_ci
3607e41f4b71Sopenharmony_ci**Parameters**
3608e41f4b71Sopenharmony_ci
3609e41f4b71Sopenharmony_ci| Name    | Type                                | Description          |
3610e41f4b71Sopenharmony_ci| ------- | ------------------------------------ | -------------- |
3611e41f4b71Sopenharmony_ci| callback | Callback\<[OnSslErrorEventReceiveEvent](#onsslerroreventreceiveevent12)\> | Callback invoked when the web page receives an SSL error.|
3612e41f4b71Sopenharmony_ci
3613e41f4b71Sopenharmony_ci**Example**
3614e41f4b71Sopenharmony_ci
3615e41f4b71Sopenharmony_ci  ```ts
3616e41f4b71Sopenharmony_ci  // xxx.ets
3617e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3618e41f4b71Sopenharmony_ci
3619e41f4b71Sopenharmony_ci  @Entry
3620e41f4b71Sopenharmony_ci  @Component
3621e41f4b71Sopenharmony_ci  struct WebComponent {
3622e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3623e41f4b71Sopenharmony_ci
3624e41f4b71Sopenharmony_ci    build() {
3625e41f4b71Sopenharmony_ci      Column() {
3626e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3627e41f4b71Sopenharmony_ci          .onSslErrorEventReceive((event) => {
3628e41f4b71Sopenharmony_ci            AlertDialog.show({
3629e41f4b71Sopenharmony_ci              title: 'onSslErrorEventReceive',
3630e41f4b71Sopenharmony_ci              message: 'text',
3631e41f4b71Sopenharmony_ci              primaryButton: {
3632e41f4b71Sopenharmony_ci                value: 'confirm',
3633e41f4b71Sopenharmony_ci                action: () => {
3634e41f4b71Sopenharmony_ci                  event.handler.handleConfirm();
3635e41f4b71Sopenharmony_ci                }
3636e41f4b71Sopenharmony_ci              },
3637e41f4b71Sopenharmony_ci              secondaryButton: {
3638e41f4b71Sopenharmony_ci                value: 'cancel',
3639e41f4b71Sopenharmony_ci                action: () => {
3640e41f4b71Sopenharmony_ci                  event.handler.handleCancel();
3641e41f4b71Sopenharmony_ci                }
3642e41f4b71Sopenharmony_ci              },
3643e41f4b71Sopenharmony_ci              cancel: () => {
3644e41f4b71Sopenharmony_ci                event.handler.handleCancel();
3645e41f4b71Sopenharmony_ci              }
3646e41f4b71Sopenharmony_ci            })
3647e41f4b71Sopenharmony_ci          })
3648e41f4b71Sopenharmony_ci      }
3649e41f4b71Sopenharmony_ci    }
3650e41f4b71Sopenharmony_ci  }
3651e41f4b71Sopenharmony_ci  ```
3652e41f4b71Sopenharmony_ci
3653e41f4b71Sopenharmony_ci### onSslErrorEvent<sup>12+</sup>
3654e41f4b71Sopenharmony_ci
3655e41f4b71Sopenharmony_cionSslErrorEvent(callback: OnSslErrorEventCallback)
3656e41f4b71Sopenharmony_ci
3657e41f4b71Sopenharmony_ciCalled to notify users when an SSL error occurs during the loading of resources (for the main frame and subframes). To handle SSL errors for requests for the main frame, use the **isMainFrame** field to distinguish.
3658e41f4b71Sopenharmony_ci
3659e41f4b71Sopenharmony_ci**Parameters**
3660e41f4b71Sopenharmony_ci
3661e41f4b71Sopenharmony_ci| Name    | Type                                | Description          |
3662e41f4b71Sopenharmony_ci| ------- | ------------------------------------ | -------------- |
3663e41f4b71Sopenharmony_ci| callback | [OnSslErrorEventCallback](#onsslerroreventcallback12) | Callback invoked when an SSL error occurs during resource loading.|
3664e41f4b71Sopenharmony_ci
3665e41f4b71Sopenharmony_ci**Example**
3666e41f4b71Sopenharmony_ci
3667e41f4b71Sopenharmony_ci  ```ts
3668e41f4b71Sopenharmony_ci  // xxx.ets
3669e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3670e41f4b71Sopenharmony_ci
3671e41f4b71Sopenharmony_ci  @Entry
3672e41f4b71Sopenharmony_ci  @Component
3673e41f4b71Sopenharmony_ci  struct WebComponent {
3674e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3675e41f4b71Sopenharmony_ci
3676e41f4b71Sopenharmony_ci    build() {
3677e41f4b71Sopenharmony_ci      Column() {
3678e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3679e41f4b71Sopenharmony_ci          .onSslErrorEvent((event: SslErrorEvent) => {
3680e41f4b71Sopenharmony_ci            console.log("onSslErrorEvent url: " + event.url);
3681e41f4b71Sopenharmony_ci            console.log("onSslErrorEvent error: " + event.error);
3682e41f4b71Sopenharmony_ci            console.log("onSslErrorEvent originalUrl: " + event.originalUrl);
3683e41f4b71Sopenharmony_ci            console.log("onSslErrorEvent referrer: " + event.referrer);
3684e41f4b71Sopenharmony_ci            console.log("onSslErrorEvent isFatalError: " + event.isFatalError);
3685e41f4b71Sopenharmony_ci            console.log("onSslErrorEvent isMainFrame: " + event.isMainFrame);
3686e41f4b71Sopenharmony_ci            AlertDialog.show({
3687e41f4b71Sopenharmony_ci              title: 'onSslErrorEvent',
3688e41f4b71Sopenharmony_ci              message: 'text',
3689e41f4b71Sopenharmony_ci              primaryButton: {
3690e41f4b71Sopenharmony_ci                value: 'confirm',
3691e41f4b71Sopenharmony_ci                action: () => {
3692e41f4b71Sopenharmony_ci                  event.handler.handleConfirm();
3693e41f4b71Sopenharmony_ci                }
3694e41f4b71Sopenharmony_ci              },
3695e41f4b71Sopenharmony_ci              secondaryButton: {
3696e41f4b71Sopenharmony_ci                value: 'cancel',
3697e41f4b71Sopenharmony_ci                action: () => {
3698e41f4b71Sopenharmony_ci                  event.handler.handleCancel();
3699e41f4b71Sopenharmony_ci                }
3700e41f4b71Sopenharmony_ci              },
3701e41f4b71Sopenharmony_ci              cancel: () => {
3702e41f4b71Sopenharmony_ci                event.handler.handleCancel();
3703e41f4b71Sopenharmony_ci              }
3704e41f4b71Sopenharmony_ci            })
3705e41f4b71Sopenharmony_ci          })
3706e41f4b71Sopenharmony_ci      }
3707e41f4b71Sopenharmony_ci    }
3708e41f4b71Sopenharmony_ci  }
3709e41f4b71Sopenharmony_ci  ```
3710e41f4b71Sopenharmony_ci
3711e41f4b71Sopenharmony_ci### onClientAuthenticationRequest<sup>9+</sup>
3712e41f4b71Sopenharmony_ci
3713e41f4b71Sopenharmony_cionClientAuthenticationRequest(callback: Callback\<OnClientAuthenticationEvent\>)
3714e41f4b71Sopenharmony_ci
3715e41f4b71Sopenharmony_ciCalled when an SSL client certificate request is received.
3716e41f4b71Sopenharmony_ci
3717e41f4b71Sopenharmony_ci**Parameters**
3718e41f4b71Sopenharmony_ci
3719e41f4b71Sopenharmony_ci| Name     | Type                                    | Description           |
3720e41f4b71Sopenharmony_ci| -------- | ---------------------------------------- | --------------- |
3721e41f4b71Sopenharmony_ci| callback  | Callback\<[OnClientAuthenticationEvent](#onclientauthenticationrequestevent12)\> | Callback invoked when an SSL client certificate is required from the user. |
3722e41f4b71Sopenharmony_ci
3723e41f4b71Sopenharmony_ci  **Example**
3724e41f4b71Sopenharmony_ci
3725e41f4b71Sopenharmony_ci  This example shows two-way authentication when interconnection with certificate management is not supported.
3726e41f4b71Sopenharmony_ci
3727e41f4b71Sopenharmony_ci  ```ts
3728e41f4b71Sopenharmony_ci  // xxx.ets API9
3729e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3730e41f4b71Sopenharmony_ci
3731e41f4b71Sopenharmony_ci  @Entry
3732e41f4b71Sopenharmony_ci  @Component
3733e41f4b71Sopenharmony_ci  struct WebComponent {
3734e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3735e41f4b71Sopenharmony_ci
3736e41f4b71Sopenharmony_ci    build() {
3737e41f4b71Sopenharmony_ci      Column() {
3738e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
3739e41f4b71Sopenharmony_ci          .onClientAuthenticationRequest((event) => {
3740e41f4b71Sopenharmony_ci            AlertDialog.show({
3741e41f4b71Sopenharmony_ci              title: 'onClientAuthenticationRequest',
3742e41f4b71Sopenharmony_ci              message: 'text',
3743e41f4b71Sopenharmony_ci              primaryButton: {
3744e41f4b71Sopenharmony_ci                value: 'confirm',
3745e41f4b71Sopenharmony_ci                action: () => {
3746e41f4b71Sopenharmony_ci                  event.handler.confirm("/system/etc/user.pk8", "/system/etc/chain-user.pem");
3747e41f4b71Sopenharmony_ci                }
3748e41f4b71Sopenharmony_ci              },
3749e41f4b71Sopenharmony_ci              secondaryButton: {
3750e41f4b71Sopenharmony_ci                value: 'cancel',
3751e41f4b71Sopenharmony_ci                action: () => {
3752e41f4b71Sopenharmony_ci                  event.handler.cancel();
3753e41f4b71Sopenharmony_ci                }
3754e41f4b71Sopenharmony_ci              },
3755e41f4b71Sopenharmony_ci              cancel: () => {
3756e41f4b71Sopenharmony_ci                event.handler.ignore();
3757e41f4b71Sopenharmony_ci              }
3758e41f4b71Sopenharmony_ci            })
3759e41f4b71Sopenharmony_ci          })
3760e41f4b71Sopenharmony_ci      }
3761e41f4b71Sopenharmony_ci    }
3762e41f4b71Sopenharmony_ci  }
3763e41f4b71Sopenharmony_ci  ```
3764e41f4b71Sopenharmony_ci
3765e41f4b71Sopenharmony_ci  This example shows two-way authentication when interconnection with certificate management is supported.
3766e41f4b71Sopenharmony_ci
3767e41f4b71Sopenharmony_ci  1. Construct the singleton object **GlobalContext**.
3768e41f4b71Sopenharmony_ci
3769e41f4b71Sopenharmony_ci     ```ts
3770e41f4b71Sopenharmony_ci     // GlobalContext.ets
3771e41f4b71Sopenharmony_ci     export class GlobalContext {
3772e41f4b71Sopenharmony_ci       private constructor() {}
3773e41f4b71Sopenharmony_ci       private static instance: GlobalContext;
3774e41f4b71Sopenharmony_ci       private _objects = new Map<string, Object>();
3775e41f4b71Sopenharmony_ci
3776e41f4b71Sopenharmony_ci       public static getContext(): GlobalContext {
3777e41f4b71Sopenharmony_ci         if (!GlobalContext.instance) {
3778e41f4b71Sopenharmony_ci           GlobalContext.instance = new GlobalContext();
3779e41f4b71Sopenharmony_ci         }
3780e41f4b71Sopenharmony_ci         return GlobalContext.instance;
3781e41f4b71Sopenharmony_ci       }
3782e41f4b71Sopenharmony_ci
3783e41f4b71Sopenharmony_ci       getObject(value: string): Object | undefined {
3784e41f4b71Sopenharmony_ci         return this._objects.get(value);
3785e41f4b71Sopenharmony_ci       }
3786e41f4b71Sopenharmony_ci
3787e41f4b71Sopenharmony_ci       setObject(key: string, objectClass: Object): void {
3788e41f4b71Sopenharmony_ci         this._objects.set(key, objectClass);
3789e41f4b71Sopenharmony_ci       }
3790e41f4b71Sopenharmony_ci     }
3791e41f4b71Sopenharmony_ci     ```
3792e41f4b71Sopenharmony_ci
3793e41f4b71Sopenharmony_ci
3794e41f4b71Sopenharmony_ci  2. Implement two-way authentication.
3795e41f4b71Sopenharmony_ci
3796e41f4b71Sopenharmony_ci     ```ts
3797e41f4b71Sopenharmony_ci     // xxx.ets API10
3798e41f4b71Sopenharmony_ci     import { webview } from '@kit.ArkWeb';
3799e41f4b71Sopenharmony_ci     import { common, Want, bundleManager } from '@kit.AbilityKit';
3800e41f4b71Sopenharmony_ci     import { BusinessError } from '@kit.BasicServicesKit';
3801e41f4b71Sopenharmony_ci     import { GlobalContext } from '../GlobalContext';
3802e41f4b71Sopenharmony_ci
3803e41f4b71Sopenharmony_ci     let uri = "";
3804e41f4b71Sopenharmony_ci
3805e41f4b71Sopenharmony_ci     export default class CertManagerService {
3806e41f4b71Sopenharmony_ci       private static sInstance: CertManagerService;
3807e41f4b71Sopenharmony_ci       private authUri = "";
3808e41f4b71Sopenharmony_ci       private appUid = "";
3809e41f4b71Sopenharmony_ci
3810e41f4b71Sopenharmony_ci       public static getInstance(): CertManagerService {
3811e41f4b71Sopenharmony_ci         if (CertManagerService.sInstance == null) {
3812e41f4b71Sopenharmony_ci           CertManagerService.sInstance = new CertManagerService();
3813e41f4b71Sopenharmony_ci         }
3814e41f4b71Sopenharmony_ci         return CertManagerService.sInstance;
3815e41f4b71Sopenharmony_ci       }
3816e41f4b71Sopenharmony_ci
3817e41f4b71Sopenharmony_ci       async grantAppPm(callback: (message: string) => void) {
3818e41f4b71Sopenharmony_ci         let message = '';
3819e41f4b71Sopenharmony_ci         let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION;
3820e41f4b71Sopenharmony_ci         // Note: Replace com.example.myapplication with the actual application name.
3821e41f4b71Sopenharmony_ci         try {
3822e41f4b71Sopenharmony_ci           bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
3823e41f4b71Sopenharmony_ci             console.info('getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
3824e41f4b71Sopenharmony_ci            this.appUid = data.appInfo.uid.toString();
3825e41f4b71Sopenharmony_ci           }).catch((err: BusinessError) => {
3826e41f4b71Sopenharmony_ci             console.error('getBundleInfoForSelf failed. Cause: %{public}s', err.message);
3827e41f4b71Sopenharmony_ci           });
3828e41f4b71Sopenharmony_ci         } catch (err) {
3829e41f4b71Sopenharmony_ci           let message = (err as BusinessError).message;
3830e41f4b71Sopenharmony_ci           console.error('getBundleInfoForSelf failed: %{public}s', message);
3831e41f4b71Sopenharmony_ci         }
3832e41f4b71Sopenharmony_ci
3833e41f4b71Sopenharmony_ci         // Note: Add GlobalContext.getContext().setObject("AbilityContext", this.context) to the onCreate function in the MainAbility.ts file.
3834e41f4b71Sopenharmony_ci         let abilityContext = GlobalContext.getContext().getObject("AbilityContext") as common.UIAbilityContext
3835e41f4b71Sopenharmony_ci         await abilityContext.startAbilityForResult(
3836e41f4b71Sopenharmony_ci           {
3837e41f4b71Sopenharmony_ci             bundleName: "com.ohos.certmanager",
3838e41f4b71Sopenharmony_ci             abilityName: "MainAbility",
3839e41f4b71Sopenharmony_ci             uri: "requestAuthorize",
3840e41f4b71Sopenharmony_ci             parameters: {
3841e41f4b71Sopenharmony_ci               appUid: this.appUid, // Pass the UID of the requesting application.
3842e41f4b71Sopenharmony_ci             }
3843e41f4b71Sopenharmony_ci           } as Want)
3844e41f4b71Sopenharmony_ci           .then((data: common.AbilityResult) => {
3845e41f4b71Sopenharmony_ci             if (!data.resultCode && data.want) {
3846e41f4b71Sopenharmony_ci               if (data.want.parameters) {
3847e41f4b71Sopenharmony_ci                 this.authUri = data.want.parameters.authUri as string; // Obtain the returned authUri after successful authorization.
3848e41f4b71Sopenharmony_ci               }
3849e41f4b71Sopenharmony_ci             }
3850e41f4b71Sopenharmony_ci           })
3851e41f4b71Sopenharmony_ci         message += "after grantAppPm authUri: " + this.authUri;
3852e41f4b71Sopenharmony_ci         uri = this.authUri;
3853e41f4b71Sopenharmony_ci         callback(message)
3854e41f4b71Sopenharmony_ci       }
3855e41f4b71Sopenharmony_ci     }
3856e41f4b71Sopenharmony_ci
3857e41f4b71Sopenharmony_ci     @Entry
3858e41f4b71Sopenharmony_ci     @Component
3859e41f4b71Sopenharmony_ci     struct WebComponent {
3860e41f4b71Sopenharmony_ci       controller: webview.WebviewController = new webview.WebviewController();
3861e41f4b71Sopenharmony_ci       @State message: string ='Hello World' // message is used for debugging and observation.
3862e41f4b71Sopenharmony_ci       certManager = CertManagerService.getInstance();
3863e41f4b71Sopenharmony_ci
3864e41f4b71Sopenharmony_ci       build() {
3865e41f4b71Sopenharmony_ci         Row() {
3866e41f4b71Sopenharmony_ci           Column() {
3867e41f4b71Sopenharmony_ci             Row() {
3868e41f4b71Sopenharmony_ci               // Step 1: Perform authorization to obtain the URI.
3869e41f4b71Sopenharmony_ci               Button('GrantApp')
3870e41f4b71Sopenharmony_ci                 .onClick(() => {
3871e41f4b71Sopenharmony_ci                   this.certManager.grantAppPm((data) => {
3872e41f4b71Sopenharmony_ci                     this.message = data;
3873e41f4b71Sopenharmony_ci                   });
3874e41f4b71Sopenharmony_ci                 })
3875e41f4b71Sopenharmony_ci               // Step 2: After the authorization, in two-way authentication, the onClientAuthenticationRequest callback is used to send the URI to the web server for authentication.
3876e41f4b71Sopenharmony_ci               Button("ClientCertAuth")
3877e41f4b71Sopenharmony_ci                 .onClick(() => {
3878e41f4b71Sopenharmony_ci                   this.controller.loadUrl('https://www.example2.com'); // Server website that supports two-way authentication.
3879e41f4b71Sopenharmony_ci                 })
3880e41f4b71Sopenharmony_ci             }
3881e41f4b71Sopenharmony_ci
3882e41f4b71Sopenharmony_ci             Web({ src: 'https://www.example1.com', controller: this.controller })
3883e41f4b71Sopenharmony_ci               .fileAccess(true)
3884e41f4b71Sopenharmony_ci               .javaScriptAccess(true)
3885e41f4b71Sopenharmony_ci               .domStorageAccess(true)
3886e41f4b71Sopenharmony_ci               .onlineImageAccess(true)
3887e41f4b71Sopenharmony_ci
3888e41f4b71Sopenharmony_ci               .onClientAuthenticationRequest((event) => {
3889e41f4b71Sopenharmony_ci                 AlertDialog.show({
3890e41f4b71Sopenharmony_ci                   title: 'ClientAuth',
3891e41f4b71Sopenharmony_ci                   message: 'Text',
3892e41f4b71Sopenharmony_ci                   confirm: {
3893e41f4b71Sopenharmony_ci                     value: 'Confirm',
3894e41f4b71Sopenharmony_ci                     action: () => {
3895e41f4b71Sopenharmony_ci                       event.handler.confirm(uri);
3896e41f4b71Sopenharmony_ci                     }
3897e41f4b71Sopenharmony_ci                   },
3898e41f4b71Sopenharmony_ci                   cancel: () => {
3899e41f4b71Sopenharmony_ci                     event.handler.cancel();
3900e41f4b71Sopenharmony_ci                   }
3901e41f4b71Sopenharmony_ci                 })
3902e41f4b71Sopenharmony_ci               })
3903e41f4b71Sopenharmony_ci           }
3904e41f4b71Sopenharmony_ci         }
3905e41f4b71Sopenharmony_ci         .width('100%')
3906e41f4b71Sopenharmony_ci         .height('100%')
3907e41f4b71Sopenharmony_ci       }
3908e41f4b71Sopenharmony_ci     }
3909e41f4b71Sopenharmony_ci     ```
3910e41f4b71Sopenharmony_ci
3911e41f4b71Sopenharmony_ci### onPermissionRequest<sup>9+</sup>
3912e41f4b71Sopenharmony_ci
3913e41f4b71Sopenharmony_cionPermissionRequest(callback: Callback\<OnPermissionRequestEvent\>)
3914e41f4b71Sopenharmony_ci
3915e41f4b71Sopenharmony_ciCalled when a permission request is received. To call this API, you need to declare the **ohos.permission.CAMERA** and **ohos.permission.MICROPHONE** permissions.
3916e41f4b71Sopenharmony_ci
3917e41f4b71Sopenharmony_ci**Parameters**
3918e41f4b71Sopenharmony_ci
3919e41f4b71Sopenharmony_ci| Name    | Type                                    | Description          |
3920e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | -------------- |
3921e41f4b71Sopenharmony_ci| callback | Callback\<[OnPermissionRequestEvent](#onpermissionrequestevent12)\> | Callback invoked when a permission request is received.|
3922e41f4b71Sopenharmony_ci
3923e41f4b71Sopenharmony_ci**Example**
3924e41f4b71Sopenharmony_ci
3925e41f4b71Sopenharmony_ci  ```ts
3926e41f4b71Sopenharmony_ci  // xxx.ets
3927e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
3928e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
3929e41f4b71Sopenharmony_ci  import { abilityAccessCtrl } from '@kit.AbilityKit';
3930e41f4b71Sopenharmony_ci
3931e41f4b71Sopenharmony_ci  @Entry
3932e41f4b71Sopenharmony_ci  @Component
3933e41f4b71Sopenharmony_ci  struct WebComponent {
3934e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
3935e41f4b71Sopenharmony_ci
3936e41f4b71Sopenharmony_ci    aboutToAppear() {
3937e41f4b71Sopenharmony_ci      // Enable web frontend page debugging.
3938e41f4b71Sopenharmony_ci      webview.WebviewController.setWebDebuggingAccess(true);
3939e41f4b71Sopenharmony_ci      let atManager = abilityAccessCtrl.createAtManager();
3940e41f4b71Sopenharmony_ci      atManager.requestPermissionsFromUser(getContext(this), ['ohos.permission.CAMERA', 'ohos.permission.MICROPHONE'])
3941e41f4b71Sopenharmony_ci        .then((data) => {
3942e41f4b71Sopenharmony_ci          console.info('data:' + JSON.stringify(data));
3943e41f4b71Sopenharmony_ci          console.info('data permissions:' + data.permissions);
3944e41f4b71Sopenharmony_ci          console.info('data authResults:' + data.authResults);
3945e41f4b71Sopenharmony_ci        }).catch((error: BusinessError) => {
3946e41f4b71Sopenharmony_ci        console.error(`Failed to request permissions from user. Code is ${error.code}, message is ${error.message}`);
3947e41f4b71Sopenharmony_ci      })
3948e41f4b71Sopenharmony_ci    }
3949e41f4b71Sopenharmony_ci
3950e41f4b71Sopenharmony_ci    build() {
3951e41f4b71Sopenharmony_ci      Column() {
3952e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
3953e41f4b71Sopenharmony_ci          .onPermissionRequest((event) => {
3954e41f4b71Sopenharmony_ci            if (event) {
3955e41f4b71Sopenharmony_ci              AlertDialog.show({
3956e41f4b71Sopenharmony_ci                title: 'title',
3957e41f4b71Sopenharmony_ci                message: 'text',
3958e41f4b71Sopenharmony_ci                primaryButton: {
3959e41f4b71Sopenharmony_ci                  value: 'deny',
3960e41f4b71Sopenharmony_ci                  action: () => {
3961e41f4b71Sopenharmony_ci                    event.request.deny();
3962e41f4b71Sopenharmony_ci                  }
3963e41f4b71Sopenharmony_ci                },
3964e41f4b71Sopenharmony_ci                secondaryButton: {
3965e41f4b71Sopenharmony_ci                  value: 'onConfirm',
3966e41f4b71Sopenharmony_ci                  action: () => {
3967e41f4b71Sopenharmony_ci                    event.request.grant(event.request.getAccessibleResource());
3968e41f4b71Sopenharmony_ci                  }
3969e41f4b71Sopenharmony_ci                },
3970e41f4b71Sopenharmony_ci                cancel: () => {
3971e41f4b71Sopenharmony_ci                  event.request.deny();
3972e41f4b71Sopenharmony_ci                }
3973e41f4b71Sopenharmony_ci              })
3974e41f4b71Sopenharmony_ci            }
3975e41f4b71Sopenharmony_ci          })
3976e41f4b71Sopenharmony_ci      }
3977e41f4b71Sopenharmony_ci    }
3978e41f4b71Sopenharmony_ci  }
3979e41f4b71Sopenharmony_ci  ```
3980e41f4b71Sopenharmony_ci
3981e41f4b71Sopenharmony_ci  HTML file to be loaded:
3982e41f4b71Sopenharmony_ci ```html
3983e41f4b71Sopenharmony_ci  <!-- index.html -->
3984e41f4b71Sopenharmony_ci  <!DOCTYPE html>
3985e41f4b71Sopenharmony_ci  <html>
3986e41f4b71Sopenharmony_ci  <head>
3987e41f4b71Sopenharmony_ci    <meta charset="UTF-8">
3988e41f4b71Sopenharmony_ci  </head>
3989e41f4b71Sopenharmony_ci  <body>
3990e41f4b71Sopenharmony_ci  <video id="video" width="500px" height="500px" autoplay="autoplay"></video>
3991e41f4b71Sopenharmony_ci  <canvas id="canvas" width="500px" height="500px"></canvas>
3992e41f4b71Sopenharmony_ci  <br>
3993e41f4b71Sopenharmony_ci  <input type="button" title="HTML5 Camera" value="Enable Camera" onclick="getMedia()"/>
3994e41f4b71Sopenharmony_ci  <script>
3995e41f4b71Sopenharmony_ci    function getMedia()
3996e41f4b71Sopenharmony_ci    {
3997e41f4b71Sopenharmony_ci      let constraints = {
3998e41f4b71Sopenharmony_ci        video: {width: 500, height: 500},
3999e41f4b71Sopenharmony_ci        audio: true
4000e41f4b71Sopenharmony_ci      };
4001e41f4b71Sopenharmony_ci      // Obtain the video camera area.
4002e41f4b71Sopenharmony_ci      let video = document.getElementById("video");
4003e41f4b71Sopenharmony_ci      // Returned Promise object
4004e41f4b71Sopenharmony_ci      let promise = navigator.mediaDevices.getUserMedia(constraints);
4005e41f4b71Sopenharmony_ci      // then() is asynchronous. Invoke the MediaStream object as a parameter.
4006e41f4b71Sopenharmony_ci      promise.then(function (MediaStream) {
4007e41f4b71Sopenharmony_ci        video.srcObject = MediaStream;
4008e41f4b71Sopenharmony_ci        video.play();
4009e41f4b71Sopenharmony_ci      });
4010e41f4b71Sopenharmony_ci    }
4011e41f4b71Sopenharmony_ci  </script>
4012e41f4b71Sopenharmony_ci  </body>
4013e41f4b71Sopenharmony_ci  </html>
4014e41f4b71Sopenharmony_ci ```
4015e41f4b71Sopenharmony_ci
4016e41f4b71Sopenharmony_ci### onContextMenuShow<sup>9+</sup>
4017e41f4b71Sopenharmony_ci
4018e41f4b71Sopenharmony_cionContextMenuShow(callback: Callback\<OnContextMenuShowEvent, boolean\>)
4019e41f4b71Sopenharmony_ci
4020e41f4b71Sopenharmony_ciCalled when a context menu is displayed after the user clicks the right mouse button or long presses a specific element, such as an image or a link.
4021e41f4b71Sopenharmony_ci
4022e41f4b71Sopenharmony_ci**Parameters**
4023e41f4b71Sopenharmony_ci
4024e41f4b71Sopenharmony_ci| Name   | Type                                    | Description       |
4025e41f4b71Sopenharmony_ci| ------ | ---------------------------------------- | ----------- |
4026e41f4b71Sopenharmony_ci| callback  | Callback\<[OnContextMenuShowEvent](#oncontextmenushowevent12), boolean\> | Callback invoked during a call to allow for the display of a custom context menu.<br>Return value: boolean<br> The value **true** means a valid custom menu, and **false** means an invalid custom menu.    |
4027e41f4b71Sopenharmony_ci
4028e41f4b71Sopenharmony_ci**Example**
4029e41f4b71Sopenharmony_ci
4030e41f4b71Sopenharmony_ci  ```ts
4031e41f4b71Sopenharmony_ci  // xxx.ets
4032e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4033e41f4b71Sopenharmony_ci  import { pasteboard } from '@kit.BasicServicesKit';
4034e41f4b71Sopenharmony_ci
4035e41f4b71Sopenharmony_ci  const TAG = 'ContextMenu';
4036e41f4b71Sopenharmony_ci
4037e41f4b71Sopenharmony_ci  @Entry
4038e41f4b71Sopenharmony_ci  @Component
4039e41f4b71Sopenharmony_ci  struct WebComponent {
4040e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4041e41f4b71Sopenharmony_ci    private result: WebContextMenuResult | undefined = undefined;
4042e41f4b71Sopenharmony_ci    @State linkUrl: string = '';
4043e41f4b71Sopenharmony_ci    @State offsetX: number = 0;
4044e41f4b71Sopenharmony_ci    @State offsetY: number = 0;
4045e41f4b71Sopenharmony_ci    @State showMenu: boolean = false;
4046e41f4b71Sopenharmony_ci
4047e41f4b71Sopenharmony_ci    @Builder
4048e41f4b71Sopenharmony_ci    // Build and trigger a custom menu.
4049e41f4b71Sopenharmony_ci    MenuBuilder() {
4050e41f4b71Sopenharmony_ci      // A component that is used to present a vertical list of items to the user.
4051e41f4b71Sopenharmony_ci      Menu() {
4052e41f4b71Sopenharmony_ci        // A component that is used to represent an item in a menu.
4053e41f4b71Sopenharmony_ci        MenuItem({
4054e41f4b71Sopenharmony_ci          content: 'Copy Image',
4055e41f4b71Sopenharmony_ci        })
4056e41f4b71Sopenharmony_ci          .width(100)
4057e41f4b71Sopenharmony_ci          .height(50)
4058e41f4b71Sopenharmony_ci          .onClick(() => {
4059e41f4b71Sopenharmony_ci            this.result?.copyImage();
4060e41f4b71Sopenharmony_ci            this.showMenu = false;
4061e41f4b71Sopenharmony_ci          })
4062e41f4b71Sopenharmony_ci        MenuItem({
4063e41f4b71Sopenharmony_ci          content: 'Cut',
4064e41f4b71Sopenharmony_ci        })
4065e41f4b71Sopenharmony_ci          .width(100)
4066e41f4b71Sopenharmony_ci          .height(50)
4067e41f4b71Sopenharmony_ci          .onClick(() => {
4068e41f4b71Sopenharmony_ci            this.result?.cut();
4069e41f4b71Sopenharmony_ci            this.showMenu = false;
4070e41f4b71Sopenharmony_ci          })
4071e41f4b71Sopenharmony_ci        MenuItem({
4072e41f4b71Sopenharmony_ci          content: 'Copy',
4073e41f4b71Sopenharmony_ci        })
4074e41f4b71Sopenharmony_ci          .width(100)
4075e41f4b71Sopenharmony_ci          .height(50)
4076e41f4b71Sopenharmony_ci          .onClick(() => {
4077e41f4b71Sopenharmony_ci            this.result?.copy();
4078e41f4b71Sopenharmony_ci            this.showMenu = false;
4079e41f4b71Sopenharmony_ci          })
4080e41f4b71Sopenharmony_ci        MenuItem({
4081e41f4b71Sopenharmony_ci          content: 'Paste',
4082e41f4b71Sopenharmony_ci        })
4083e41f4b71Sopenharmony_ci          .width(100)
4084e41f4b71Sopenharmony_ci          .height(50)
4085e41f4b71Sopenharmony_ci          .onClick(() => {
4086e41f4b71Sopenharmony_ci            this.result?.paste();
4087e41f4b71Sopenharmony_ci            this.showMenu = false;
4088e41f4b71Sopenharmony_ci          })
4089e41f4b71Sopenharmony_ci        MenuItem({
4090e41f4b71Sopenharmony_ci          content: 'Copy Link',
4091e41f4b71Sopenharmony_ci        })
4092e41f4b71Sopenharmony_ci          .width(100)
4093e41f4b71Sopenharmony_ci          .height(50)
4094e41f4b71Sopenharmony_ci          .onClick(() => {
4095e41f4b71Sopenharmony_ci            let pasteData = pasteboard.createData('text/plain', this.linkUrl);
4096e41f4b71Sopenharmony_ci            pasteboard.getSystemPasteboard().setData(pasteData, (error) => {
4097e41f4b71Sopenharmony_ci              if (error) {
4098e41f4b71Sopenharmony_ci                return;
4099e41f4b71Sopenharmony_ci              }
4100e41f4b71Sopenharmony_ci            })
4101e41f4b71Sopenharmony_ci            this.showMenu = false;
4102e41f4b71Sopenharmony_ci          })
4103e41f4b71Sopenharmony_ci        MenuItem({
4104e41f4b71Sopenharmony_ci          content: 'Select All',
4105e41f4b71Sopenharmony_ci        })
4106e41f4b71Sopenharmony_ci          .width(100)
4107e41f4b71Sopenharmony_ci          .height(50)
4108e41f4b71Sopenharmony_ci          .onClick(() => {
4109e41f4b71Sopenharmony_ci            this.result?.selectAll();
4110e41f4b71Sopenharmony_ci            this.showMenu = false;
4111e41f4b71Sopenharmony_ci          })
4112e41f4b71Sopenharmony_ci      }
4113e41f4b71Sopenharmony_ci      .width(150)
4114e41f4b71Sopenharmony_ci      .height(300)
4115e41f4b71Sopenharmony_ci    }
4116e41f4b71Sopenharmony_ci
4117e41f4b71Sopenharmony_ci    build() {
4118e41f4b71Sopenharmony_ci      Column() {
4119e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
4120e41f4b71Sopenharmony_ci          // Trigger a custom dialog box.
4121e41f4b71Sopenharmony_ci          .onContextMenuShow((event) => {
4122e41f4b71Sopenharmony_ci            if (event) {
4123e41f4b71Sopenharmony_ci              this.result = event.result
4124e41f4b71Sopenharmony_ci              console.info("x coord = " + event.param.x());
4125e41f4b71Sopenharmony_ci              console.info("link url = " + event.param.getLinkUrl());
4126e41f4b71Sopenharmony_ci              this.linkUrl = event.param.getLinkUrl();
4127e41f4b71Sopenharmony_ci            }
4128e41f4b71Sopenharmony_ci            console.info(TAG, `x: ${this.offsetX}, y: ${this.offsetY}`);
4129e41f4b71Sopenharmony_ci            this.showMenu = true;
4130e41f4b71Sopenharmony_ci            this.offsetX = 250;
4131e41f4b71Sopenharmony_ci            this.offsetY = Math.max(px2vp(event?.param.y() ?? 0) - 0, 0);
4132e41f4b71Sopenharmony_ci            return true;
4133e41f4b71Sopenharmony_ci          })
4134e41f4b71Sopenharmony_ci          .bindPopup(this.showMenu,
4135e41f4b71Sopenharmony_ci            {
4136e41f4b71Sopenharmony_ci              builder: this.MenuBuilder(),
4137e41f4b71Sopenharmony_ci              enableArrow: false,
4138e41f4b71Sopenharmony_ci              placement: Placement.LeftTop,
4139e41f4b71Sopenharmony_ci              offset: { x: this.offsetX, y: this.offsetY },
4140e41f4b71Sopenharmony_ci              mask: false,
4141e41f4b71Sopenharmony_ci              onStateChange: (e) => {
4142e41f4b71Sopenharmony_ci                if (!e.isVisible) {
4143e41f4b71Sopenharmony_ci                  this.showMenu = false;
4144e41f4b71Sopenharmony_ci                  this.result!.closeContextMenu();
4145e41f4b71Sopenharmony_ci                }
4146e41f4b71Sopenharmony_ci              }
4147e41f4b71Sopenharmony_ci            })
4148e41f4b71Sopenharmony_ci      }
4149e41f4b71Sopenharmony_ci    }
4150e41f4b71Sopenharmony_ci  }
4151e41f4b71Sopenharmony_ci  ```
4152e41f4b71Sopenharmony_ci
4153e41f4b71Sopenharmony_ci  HTML file to be loaded:
4154e41f4b71Sopenharmony_ci  ```html
4155e41f4b71Sopenharmony_ci  <!-- index.html -->
4156e41f4b71Sopenharmony_ci  <!DOCTYPE html>
4157e41f4b71Sopenharmony_ci  <html lang="en">
4158e41f4b71Sopenharmony_ci  <body>
4159e41f4b71Sopenharmony_ci    <h1>onContextMenuShow</h1>
4160e41f4b71Sopenharmony_ci    <a href="http://www.example.com" style="font-size:27px">URL www.example.com</a>
4161e41f4b71Sopenharmony_ci    // Place any image in the rawfile directory and name it example.png.
4162e41f4b71Sopenharmony_ci    <div><img src="example.png"></div>
4163e41f4b71Sopenharmony_ci    <p>Right-click text to display the context menu</p>
4164e41f4b71Sopenharmony_ci  </body>
4165e41f4b71Sopenharmony_ci  </html>
4166e41f4b71Sopenharmony_ci  ```
4167e41f4b71Sopenharmony_ci
4168e41f4b71Sopenharmony_ci### onContextMenuHide<sup>11+</sup>
4169e41f4b71Sopenharmony_ci
4170e41f4b71Sopenharmony_cionContextMenuHide(callback: OnContextMenuHideCallback)
4171e41f4b71Sopenharmony_ci
4172e41f4b71Sopenharmony_ciCalled when a context menu is hidden after the user clicks the right mouse button or long presses a specific element, such as an image or a link.
4173e41f4b71Sopenharmony_ci
4174e41f4b71Sopenharmony_ci**Parameters**
4175e41f4b71Sopenharmony_ci
4176e41f4b71Sopenharmony_ci| Name   | Type                                    | Description       |
4177e41f4b71Sopenharmony_ci| ------ | ---------------------------------------- | ----------- |
4178e41f4b71Sopenharmony_ci| callback  | [OnContextMenuHideCallback](#oncontextmenuhidecallback11) | Parameters related to the context menu.    |
4179e41f4b71Sopenharmony_ci
4180e41f4b71Sopenharmony_ci**Example**
4181e41f4b71Sopenharmony_ci
4182e41f4b71Sopenharmony_ci  ```ts
4183e41f4b71Sopenharmony_ci  // xxx.ets
4184e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4185e41f4b71Sopenharmony_ci
4186e41f4b71Sopenharmony_ci  @Entry
4187e41f4b71Sopenharmony_ci  @Component
4188e41f4b71Sopenharmony_ci  struct WebComponent {
4189e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4190e41f4b71Sopenharmony_ci
4191e41f4b71Sopenharmony_ci    build() {
4192e41f4b71Sopenharmony_ci      Column() {
4193e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4194e41f4b71Sopenharmony_ci          .onContextMenuHide(() => {
4195e41f4b71Sopenharmony_ci            console.log("onContextMenuHide callback");
4196e41f4b71Sopenharmony_ci          })
4197e41f4b71Sopenharmony_ci      }
4198e41f4b71Sopenharmony_ci    }
4199e41f4b71Sopenharmony_ci  }
4200e41f4b71Sopenharmony_ci  ```
4201e41f4b71Sopenharmony_ci
4202e41f4b71Sopenharmony_ci### onScroll<sup>9+</sup>
4203e41f4b71Sopenharmony_ci
4204e41f4b71Sopenharmony_cionScroll(callback: Callback\<OnScrollEvent\>): WebAttribute;
4205e41f4b71Sopenharmony_ci
4206e41f4b71Sopenharmony_ciCalled when the scrollbar of the page scrolls.
4207e41f4b71Sopenharmony_ci
4208e41f4b71Sopenharmony_ci**Parameters**
4209e41f4b71Sopenharmony_ci
4210e41f4b71Sopenharmony_ci| Name    | Type  | Description                  |
4211e41f4b71Sopenharmony_ci| ------- | ------ | ---------------------- |
4212e41f4b71Sopenharmony_ci| callback | Callback\<[OnScrollEvent](#onscrollevent12)\> | Callback invoked when the scrollbar scrolls to a specified position.|
4213e41f4b71Sopenharmony_ci
4214e41f4b71Sopenharmony_ci**Example**
4215e41f4b71Sopenharmony_ci
4216e41f4b71Sopenharmony_ci  ```ts
4217e41f4b71Sopenharmony_ci  // xxx.ets
4218e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4219e41f4b71Sopenharmony_ci
4220e41f4b71Sopenharmony_ci  @Entry
4221e41f4b71Sopenharmony_ci  @Component
4222e41f4b71Sopenharmony_ci  struct WebComponent {
4223e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4224e41f4b71Sopenharmony_ci
4225e41f4b71Sopenharmony_ci    build() {
4226e41f4b71Sopenharmony_ci      Column() {
4227e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4228e41f4b71Sopenharmony_ci          .onScroll((event) => {
4229e41f4b71Sopenharmony_ci            console.info("x = " + event.xOffset);
4230e41f4b71Sopenharmony_ci            console.info("y = " + event.yOffset);
4231e41f4b71Sopenharmony_ci          })
4232e41f4b71Sopenharmony_ci      }
4233e41f4b71Sopenharmony_ci    }
4234e41f4b71Sopenharmony_ci  }
4235e41f4b71Sopenharmony_ci  ```
4236e41f4b71Sopenharmony_ci
4237e41f4b71Sopenharmony_ci### onGeolocationShow
4238e41f4b71Sopenharmony_ci
4239e41f4b71Sopenharmony_cionGeolocationShow(callback: Callback\<OnGeolocationShowEvent\>)
4240e41f4b71Sopenharmony_ci
4241e41f4b71Sopenharmony_ciCalled when a request to obtain the geolocation information is received.
4242e41f4b71Sopenharmony_ci
4243e41f4b71Sopenharmony_ci**Parameters**
4244e41f4b71Sopenharmony_ci
4245e41f4b71Sopenharmony_ci| Name        | Type                           | Description          |
4246e41f4b71Sopenharmony_ci| ----------- | ------------------------------- | -------------- |
4247e41f4b71Sopenharmony_ci| callback      | Callback\<[OnGeolocationShowEvent](#ongeolocationshowevent12)\>  | Callback invoked when a request to obtain the geolocation information is received.    |
4248e41f4b71Sopenharmony_ci
4249e41f4b71Sopenharmony_ci**Example**
4250e41f4b71Sopenharmony_ci
4251e41f4b71Sopenharmony_ci  ```ts
4252e41f4b71Sopenharmony_ci  // xxx.ets
4253e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4254e41f4b71Sopenharmony_ci
4255e41f4b71Sopenharmony_ci  @Entry
4256e41f4b71Sopenharmony_ci  @Component
4257e41f4b71Sopenharmony_ci  struct WebComponent {
4258e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4259e41f4b71Sopenharmony_ci
4260e41f4b71Sopenharmony_ci    build() {
4261e41f4b71Sopenharmony_ci      Column() {
4262e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
4263e41f4b71Sopenharmony_ci          .geolocationAccess(true)
4264e41f4b71Sopenharmony_ci          .onGeolocationShow((event) => {
4265e41f4b71Sopenharmony_ci            if (event) {
4266e41f4b71Sopenharmony_ci              AlertDialog.show({
4267e41f4b71Sopenharmony_ci                title: 'title',
4268e41f4b71Sopenharmony_ci                message: 'text',
4269e41f4b71Sopenharmony_ci                confirm: {
4270e41f4b71Sopenharmony_ci                  value: 'onConfirm',
4271e41f4b71Sopenharmony_ci                  action: () => {
4272e41f4b71Sopenharmony_ci                    event.geolocation.invoke(event.origin, true, true);
4273e41f4b71Sopenharmony_ci                  }
4274e41f4b71Sopenharmony_ci                },
4275e41f4b71Sopenharmony_ci                cancel: () => {
4276e41f4b71Sopenharmony_ci                  event.geolocation.invoke(event.origin, false, true);
4277e41f4b71Sopenharmony_ci                }
4278e41f4b71Sopenharmony_ci              })
4279e41f4b71Sopenharmony_ci            }
4280e41f4b71Sopenharmony_ci          })
4281e41f4b71Sopenharmony_ci      }
4282e41f4b71Sopenharmony_ci    }
4283e41f4b71Sopenharmony_ci  }
4284e41f4b71Sopenharmony_ci  ```
4285e41f4b71Sopenharmony_ci
4286e41f4b71Sopenharmony_ci  HTML file to be loaded:
4287e41f4b71Sopenharmony_ci  ```html
4288e41f4b71Sopenharmony_ci  <!DOCTYPE html>
4289e41f4b71Sopenharmony_ci  <html>
4290e41f4b71Sopenharmony_ci  <body>
4291e41f4b71Sopenharmony_ci  <p id="locationInfo">Location information</p>
4292e41f4b71Sopenharmony_ci  <button onclick="getLocation()">Get Location</button>
4293e41f4b71Sopenharmony_ci  <script>
4294e41f4b71Sopenharmony_ci  var locationInfo=document.getElementById("locationInfo");
4295e41f4b71Sopenharmony_ci  function getLocation(){
4296e41f4b71Sopenharmony_ci    if (navigator.geolocation) {
4297e41f4b71Sopenharmony_ci      <!-- Access to the device location by the frontend page -->
4298e41f4b71Sopenharmony_ci      navigator.geolocation.getCurrentPosition(showPosition);
4299e41f4b71Sopenharmony_ci    }
4300e41f4b71Sopenharmony_ci  }
4301e41f4b71Sopenharmony_ci  function showPosition(position){
4302e41f4b71Sopenharmony_ci    locationInfo.innerHTML="Latitude: " + position.coords.latitude + "<br />Longitude: " + position.coords.longitude;
4303e41f4b71Sopenharmony_ci  }
4304e41f4b71Sopenharmony_ci  </script>
4305e41f4b71Sopenharmony_ci  </body>
4306e41f4b71Sopenharmony_ci  </html>
4307e41f4b71Sopenharmony_ci  ```
4308e41f4b71Sopenharmony_ci
4309e41f4b71Sopenharmony_ci### onGeolocationHide
4310e41f4b71Sopenharmony_ci
4311e41f4b71Sopenharmony_cionGeolocationHide(callback: () => void)
4312e41f4b71Sopenharmony_ci
4313e41f4b71Sopenharmony_ciCalled to notify the user that the request for obtaining the geolocation information received when [onGeolocationShow](#ongeolocationshow) is called has been canceled.
4314e41f4b71Sopenharmony_ci
4315e41f4b71Sopenharmony_ci**Parameters**
4316e41f4b71Sopenharmony_ci
4317e41f4b71Sopenharmony_ci| Name     | Type      | Description                |
4318e41f4b71Sopenharmony_ci| -------- | ---------- | -------------------- |
4319e41f4b71Sopenharmony_ci| callback | () => void | Callback invoked when the request for obtaining geolocation information has been canceled. |
4320e41f4b71Sopenharmony_ci
4321e41f4b71Sopenharmony_ci**Example**
4322e41f4b71Sopenharmony_ci
4323e41f4b71Sopenharmony_ci  ```ts
4324e41f4b71Sopenharmony_ci  // xxx.ets
4325e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4326e41f4b71Sopenharmony_ci
4327e41f4b71Sopenharmony_ci  @Entry
4328e41f4b71Sopenharmony_ci  @Component
4329e41f4b71Sopenharmony_ci  struct WebComponent {
4330e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4331e41f4b71Sopenharmony_ci
4332e41f4b71Sopenharmony_ci    build() {
4333e41f4b71Sopenharmony_ci      Column() {
4334e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4335e41f4b71Sopenharmony_ci          .geolocationAccess(true)
4336e41f4b71Sopenharmony_ci          .onGeolocationHide(() => {
4337e41f4b71Sopenharmony_ci            console.log("onGeolocationHide...");
4338e41f4b71Sopenharmony_ci          })
4339e41f4b71Sopenharmony_ci      }
4340e41f4b71Sopenharmony_ci    }
4341e41f4b71Sopenharmony_ci  }
4342e41f4b71Sopenharmony_ci  ```
4343e41f4b71Sopenharmony_ci
4344e41f4b71Sopenharmony_ci### onFullScreenEnter<sup>9+</sup>
4345e41f4b71Sopenharmony_ci
4346e41f4b71Sopenharmony_cionFullScreenEnter(callback: OnFullScreenEnterCallback)
4347e41f4b71Sopenharmony_ci
4348e41f4b71Sopenharmony_ciCalled when the **Web** component enters full screen mode.
4349e41f4b71Sopenharmony_ci
4350e41f4b71Sopenharmony_ci**Parameters**
4351e41f4b71Sopenharmony_ci
4352e41f4b71Sopenharmony_ci| Name    | Type                                    | Description          |
4353e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | -------------- |
4354e41f4b71Sopenharmony_ci| callback | [OnFullScreenEnterCallback](#onfullscreenentercallback12) | Callback invoked when the **Web** component enters full screen mode.|
4355e41f4b71Sopenharmony_ci
4356e41f4b71Sopenharmony_ci**Example**
4357e41f4b71Sopenharmony_ci
4358e41f4b71Sopenharmony_ci  ```ts
4359e41f4b71Sopenharmony_ci  // xxx.ets
4360e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4361e41f4b71Sopenharmony_ci
4362e41f4b71Sopenharmony_ci  @Entry
4363e41f4b71Sopenharmony_ci  @Component
4364e41f4b71Sopenharmony_ci  struct WebComponent {
4365e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4366e41f4b71Sopenharmony_ci    handler: FullScreenExitHandler | null = null;
4367e41f4b71Sopenharmony_ci
4368e41f4b71Sopenharmony_ci    build() {
4369e41f4b71Sopenharmony_ci      Column() {
4370e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4371e41f4b71Sopenharmony_ci          .onFullScreenEnter((event) => {
4372e41f4b71Sopenharmony_ci            console.log("onFullScreenEnter videoWidth: " + event.videoWidth +
4373e41f4b71Sopenharmony_ci              ", videoHeight: " + event.videoHeight);
4374e41f4b71Sopenharmony_ci            // The application can proactively exit fullscreen mode by calling this.handler.exitFullScreen().
4375e41f4b71Sopenharmony_ci            this.handler = event.handler;
4376e41f4b71Sopenharmony_ci          })
4377e41f4b71Sopenharmony_ci      }
4378e41f4b71Sopenharmony_ci    }
4379e41f4b71Sopenharmony_ci  }
4380e41f4b71Sopenharmony_ci  ```
4381e41f4b71Sopenharmony_ci
4382e41f4b71Sopenharmony_ci### onFullScreenExit<sup>9+</sup>
4383e41f4b71Sopenharmony_ci
4384e41f4b71Sopenharmony_cionFullScreenExit(callback: () => void)
4385e41f4b71Sopenharmony_ci
4386e41f4b71Sopenharmony_ciCalled when the **Web** component exits full screen mode.
4387e41f4b71Sopenharmony_ci
4388e41f4b71Sopenharmony_ci**Parameters**
4389e41f4b71Sopenharmony_ci
4390e41f4b71Sopenharmony_ci| Name     | Type      | Description         |
4391e41f4b71Sopenharmony_ci| -------- | ---------- | ------------- |
4392e41f4b71Sopenharmony_ci| callback | () => void | Callback invoked when the component exits full screen mode.|
4393e41f4b71Sopenharmony_ci
4394e41f4b71Sopenharmony_ci**Example**
4395e41f4b71Sopenharmony_ci
4396e41f4b71Sopenharmony_ci  ```ts
4397e41f4b71Sopenharmony_ci  // xxx.ets
4398e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4399e41f4b71Sopenharmony_ci
4400e41f4b71Sopenharmony_ci  @Entry
4401e41f4b71Sopenharmony_ci  @Component
4402e41f4b71Sopenharmony_ci  struct WebComponent {
4403e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4404e41f4b71Sopenharmony_ci    handler: FullScreenExitHandler | null = null;
4405e41f4b71Sopenharmony_ci
4406e41f4b71Sopenharmony_ci    build() {
4407e41f4b71Sopenharmony_ci      Column() {
4408e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4409e41f4b71Sopenharmony_ci          .onFullScreenExit(() => {
4410e41f4b71Sopenharmony_ci            console.log("onFullScreenExit...")
4411e41f4b71Sopenharmony_ci            if (this.handler) {
4412e41f4b71Sopenharmony_ci              this.handler.exitFullScreen();
4413e41f4b71Sopenharmony_ci            }
4414e41f4b71Sopenharmony_ci          })
4415e41f4b71Sopenharmony_ci          .onFullScreenEnter((event) => {
4416e41f4b71Sopenharmony_ci            this.handler = event.handler;
4417e41f4b71Sopenharmony_ci          })
4418e41f4b71Sopenharmony_ci      }
4419e41f4b71Sopenharmony_ci    }
4420e41f4b71Sopenharmony_ci  }
4421e41f4b71Sopenharmony_ci  ```
4422e41f4b71Sopenharmony_ci
4423e41f4b71Sopenharmony_ci### onWindowNew<sup>9+</sup>
4424e41f4b71Sopenharmony_ci
4425e41f4b71Sopenharmony_cionWindowNew(callback: Callback\<OnWindowNewEvent\>)
4426e41f4b71Sopenharmony_ci
4427e41f4b71Sopenharmony_ciCalled to notify the user of a new window creation request, when **multiWindowAccess** is enabled.
4428e41f4b71Sopenharmony_ciIf the **event.handler.setWebController** API is not called, the render process will be blocked.
4429e41f4b71Sopenharmony_ciIf opening a new window is not needed, set the parameter to **null** when calling the **event.handler.setWebController** API.
4430e41f4b71Sopenharmony_ci
4431e41f4b71Sopenharmony_ciThe new window should not cover the original **Web** component, otherwise, users may be misled to other websites. If the application displays the URL of the home page, ensure that the URL of the new window is displayed in a similar way. Otherwise, new windows should be prohibited.
4432e41f4b71Sopenharmony_ci
4433e41f4b71Sopenharmony_ciNote that there is no reliable method to determine which page requests a new window. The request may be from a third-party iframe.
4434e41f4b71Sopenharmony_ci
4435e41f4b71Sopenharmony_ci**Parameters**
4436e41f4b71Sopenharmony_ci
4437e41f4b71Sopenharmony_ci| Name          | Type                                    | Description                         |
4438e41f4b71Sopenharmony_ci| ------------- | ---------------------------------------- | ----------------------------- |
4439e41f4b71Sopenharmony_ci| callback       | Callback\<[OnWindowNewEvent](#onwindownewevent12)\>                                  | Callback invoked when the web page requests the user to create a new window.   |
4440e41f4b71Sopenharmony_ci
4441e41f4b71Sopenharmony_ci**Example**
4442e41f4b71Sopenharmony_ci
4443e41f4b71Sopenharmony_ci  ```ts
4444e41f4b71Sopenharmony_ci  // xxx.ets
4445e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4446e41f4b71Sopenharmony_ci
4447e41f4b71Sopenharmony_ci  // There are two **Web** components on the same page. When the **Web** component opens a new window, **NewWebViewComp** is displayed. 
4448e41f4b71Sopenharmony_ci  @CustomDialog
4449e41f4b71Sopenharmony_ci  struct NewWebViewComp {
4450e41f4b71Sopenharmony_ci    controller?: CustomDialogController;
4451e41f4b71Sopenharmony_ci    webviewController1: webview.WebviewController = new webview.WebviewController();
4452e41f4b71Sopenharmony_ci
4453e41f4b71Sopenharmony_ci    build() {
4454e41f4b71Sopenharmony_ci      Column() {
4455e41f4b71Sopenharmony_ci        Web({ src: "", controller: this.webviewController1 })
4456e41f4b71Sopenharmony_ci          .javaScriptAccess(true)
4457e41f4b71Sopenharmony_ci          .multiWindowAccess(false)
4458e41f4b71Sopenharmony_ci          .onWindowExit(() => {
4459e41f4b71Sopenharmony_ci            console.info("NewWebViewComp onWindowExit");
4460e41f4b71Sopenharmony_ci            if (this.controller) {
4461e41f4b71Sopenharmony_ci              this.controller.close();
4462e41f4b71Sopenharmony_ci            }
4463e41f4b71Sopenharmony_ci          })
4464e41f4b71Sopenharmony_ci      }
4465e41f4b71Sopenharmony_ci    }
4466e41f4b71Sopenharmony_ci  }
4467e41f4b71Sopenharmony_ci
4468e41f4b71Sopenharmony_ci  @Entry
4469e41f4b71Sopenharmony_ci  @Component
4470e41f4b71Sopenharmony_ci  struct WebComponent {
4471e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4472e41f4b71Sopenharmony_ci    dialogController: CustomDialogController | null = null;
4473e41f4b71Sopenharmony_ci
4474e41f4b71Sopenharmony_ci    build() {
4475e41f4b71Sopenharmony_ci      Column() {
4476e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4477e41f4b71Sopenharmony_ci          .javaScriptAccess(true)
4478e41f4b71Sopenharmony_ci          // MultiWindowAccess needs to be enabled.
4479e41f4b71Sopenharmony_ci          .multiWindowAccess(true)
4480e41f4b71Sopenharmony_ci          .allowWindowOpenMethod(true)
4481e41f4b71Sopenharmony_ci          .onWindowNew((event) => {
4482e41f4b71Sopenharmony_ci            if (this.dialogController) {
4483e41f4b71Sopenharmony_ci              this.dialogController.close();
4484e41f4b71Sopenharmony_ci            }
4485e41f4b71Sopenharmony_ci            let popController: webview.WebviewController = new webview.WebviewController();
4486e41f4b71Sopenharmony_ci            this.dialogController = new CustomDialogController({
4487e41f4b71Sopenharmony_ci              builder: NewWebViewComp({ webviewController1: popController })
4488e41f4b71Sopenharmony_ci            })
4489e41f4b71Sopenharmony_ci            this.dialogController.open();
4490e41f4b71Sopenharmony_ci            // Return the WebviewController object corresponding to the new window to the <Web> kernel.
4491e41f4b71Sopenharmony_ci            // If opening a new window is not needed, set the parameter to null when calling the event.handler.setWebController API.
4492e41f4b71Sopenharmony_ci            // If the event.handler.setWebController API is not called, the render process will be blocked.
4493e41f4b71Sopenharmony_ci            event.handler.setWebController(popController);
4494e41f4b71Sopenharmony_ci          })
4495e41f4b71Sopenharmony_ci      }
4496e41f4b71Sopenharmony_ci    }
4497e41f4b71Sopenharmony_ci  }
4498e41f4b71Sopenharmony_ci  ```
4499e41f4b71Sopenharmony_ci
4500e41f4b71Sopenharmony_ci### onWindowExit<sup>9+</sup>
4501e41f4b71Sopenharmony_ci
4502e41f4b71Sopenharmony_cionWindowExit(callback: () => void)
4503e41f4b71Sopenharmony_ci
4504e41f4b71Sopenharmony_ciCalled when this window is closed. This API works in the same way as [onWindowNew](#onwindownew9). For security, applications should notify users that the pages they interact with are closed.
4505e41f4b71Sopenharmony_ci
4506e41f4b71Sopenharmony_ci**Parameters**
4507e41f4b71Sopenharmony_ci
4508e41f4b71Sopenharmony_ci| Name     | Type      | Description        |
4509e41f4b71Sopenharmony_ci| -------- | ---------- | ------------ |
4510e41f4b71Sopenharmony_ci| callback | () => void | Callback invoked when the window is closed.|
4511e41f4b71Sopenharmony_ci
4512e41f4b71Sopenharmony_ci**Example**
4513e41f4b71Sopenharmony_ci
4514e41f4b71Sopenharmony_ci  ```ts
4515e41f4b71Sopenharmony_ci  // xxx.ets
4516e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4517e41f4b71Sopenharmony_ci
4518e41f4b71Sopenharmony_ci  @Entry
4519e41f4b71Sopenharmony_ci  @Component
4520e41f4b71Sopenharmony_ci  struct WebComponent {
4521e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4522e41f4b71Sopenharmony_ci
4523e41f4b71Sopenharmony_ci    build() {
4524e41f4b71Sopenharmony_ci      Column() {
4525e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4526e41f4b71Sopenharmony_ci          .onWindowExit(() => {
4527e41f4b71Sopenharmony_ci            console.log("onWindowExit...");
4528e41f4b71Sopenharmony_ci          })
4529e41f4b71Sopenharmony_ci      }
4530e41f4b71Sopenharmony_ci    }
4531e41f4b71Sopenharmony_ci  }
4532e41f4b71Sopenharmony_ci  ```
4533e41f4b71Sopenharmony_ci
4534e41f4b71Sopenharmony_ci### onSearchResultReceive<sup>9+</sup>
4535e41f4b71Sopenharmony_ci
4536e41f4b71Sopenharmony_cionSearchResultReceive(callback: Callback\<OnSearchResultReceiveEvent\>)
4537e41f4b71Sopenharmony_ci
4538e41f4b71Sopenharmony_ciCalled to notify the caller of the search result on the web page.
4539e41f4b71Sopenharmony_ci
4540e41f4b71Sopenharmony_ci**Parameters**
4541e41f4b71Sopenharmony_ci
4542e41f4b71Sopenharmony_ci| Name               | Type   | Description                                    |
4543e41f4b71Sopenharmony_ci| ------------------ | ------- | ---------------------------------------- |
4544e41f4b71Sopenharmony_ci| callback | Callback\<[OnSearchResultReceiveEvent](#onsearchresultreceiveevent12)\>  | Callback invoked to notify the caller of the search result on the web page.        |
4545e41f4b71Sopenharmony_ci
4546e41f4b71Sopenharmony_ci**Example**
4547e41f4b71Sopenharmony_ci
4548e41f4b71Sopenharmony_ci  ```ts
4549e41f4b71Sopenharmony_ci  // xxx.ets
4550e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4551e41f4b71Sopenharmony_ci
4552e41f4b71Sopenharmony_ci  @Entry
4553e41f4b71Sopenharmony_ci  @Component
4554e41f4b71Sopenharmony_ci  struct WebComponent {
4555e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4556e41f4b71Sopenharmony_ci
4557e41f4b71Sopenharmony_ci    build() {
4558e41f4b71Sopenharmony_ci      Column() {
4559e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4560e41f4b71Sopenharmony_ci          .onSearchResultReceive(ret => {
4561e41f4b71Sopenharmony_ci            if (ret) {
4562e41f4b71Sopenharmony_ci              console.log("on search result receive:" + "[cur]" + ret.activeMatchOrdinal +
4563e41f4b71Sopenharmony_ci                "[total]" + ret.numberOfMatches + "[isDone]" + ret.isDoneCounting);
4564e41f4b71Sopenharmony_ci            }
4565e41f4b71Sopenharmony_ci          })
4566e41f4b71Sopenharmony_ci      }
4567e41f4b71Sopenharmony_ci    }
4568e41f4b71Sopenharmony_ci  }
4569e41f4b71Sopenharmony_ci  ```
4570e41f4b71Sopenharmony_ci
4571e41f4b71Sopenharmony_ci### onDataResubmitted<sup>9+</sup>
4572e41f4b71Sopenharmony_ci
4573e41f4b71Sopenharmony_cionDataResubmitted(callback: Callback\<OnDataResubmittedEvent\>)
4574e41f4b71Sopenharmony_ci
4575e41f4b71Sopenharmony_ciCalled when the web form data can be resubmitted.
4576e41f4b71Sopenharmony_ci
4577e41f4b71Sopenharmony_ci**Parameters**
4578e41f4b71Sopenharmony_ci
4579e41f4b71Sopenharmony_ci| Name    | Type                                    | Description       |
4580e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | ----------- |
4581e41f4b71Sopenharmony_ci| callback | Callback\<[OnDataResubmittedEvent](#ondataresubmittedevent12)\> | Callback invoked when the web form data can be resubmitted.|
4582e41f4b71Sopenharmony_ci
4583e41f4b71Sopenharmony_ci**Example**
4584e41f4b71Sopenharmony_ci
4585e41f4b71Sopenharmony_ci  ```ts
4586e41f4b71Sopenharmony_ci  // xxx.ets
4587e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4588e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
4589e41f4b71Sopenharmony_ci
4590e41f4b71Sopenharmony_ci  @Entry
4591e41f4b71Sopenharmony_ci  @Component
4592e41f4b71Sopenharmony_ci  struct WebComponent {
4593e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4594e41f4b71Sopenharmony_ci
4595e41f4b71Sopenharmony_ci    build() {
4596e41f4b71Sopenharmony_ci      Column() {
4597e41f4b71Sopenharmony_ci        // After you click Submit on the web page, you can click Refresh to trigger the function again.
4598e41f4b71Sopenharmony_ci        Button('refresh')
4599e41f4b71Sopenharmony_ci          .onClick(() => {
4600e41f4b71Sopenharmony_ci            try {
4601e41f4b71Sopenharmony_ci              this.controller.refresh();
4602e41f4b71Sopenharmony_ci            } catch (error) {
4603e41f4b71Sopenharmony_ci              console.error(`ErrorCode: ${(error as BusinessError).code},  Message: ${(error as BusinessError).message}`);
4604e41f4b71Sopenharmony_ci            }
4605e41f4b71Sopenharmony_ci          })
4606e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
4607e41f4b71Sopenharmony_ci          .onDataResubmitted((event) => {
4608e41f4b71Sopenharmony_ci            console.log('onDataResubmitted');
4609e41f4b71Sopenharmony_ci            event.handler.resend();
4610e41f4b71Sopenharmony_ci          })
4611e41f4b71Sopenharmony_ci      }
4612e41f4b71Sopenharmony_ci    }
4613e41f4b71Sopenharmony_ci  }
4614e41f4b71Sopenharmony_ci  ```
4615e41f4b71Sopenharmony_ci
4616e41f4b71Sopenharmony_ci HTML file to be loaded:
4617e41f4b71Sopenharmony_ci ```html
4618e41f4b71Sopenharmony_ci  <!-- index.html -->
4619e41f4b71Sopenharmony_ci  <!DOCTYPE html>
4620e41f4b71Sopenharmony_ci  <html>
4621e41f4b71Sopenharmony_ci  <head>
4622e41f4b71Sopenharmony_ci    <meta charset="utf-8">
4623e41f4b71Sopenharmony_ci  </head>
4624e41f4b71Sopenharmony_ci  <body>
4625e41f4b71Sopenharmony_ci    <form action="http://httpbin.org/post" method="post">
4626e41f4b71Sopenharmony_ci      <input type="text" name="username">
4627e41f4b71Sopenharmony_ci      <input type="submit" name="Submit">
4628e41f4b71Sopenharmony_ci    </form>
4629e41f4b71Sopenharmony_ci  </body>
4630e41f4b71Sopenharmony_ci  </html>
4631e41f4b71Sopenharmony_ci ```
4632e41f4b71Sopenharmony_ci
4633e41f4b71Sopenharmony_ci### onPageVisible<sup>9+</sup>
4634e41f4b71Sopenharmony_ci
4635e41f4b71Sopenharmony_cionPageVisible(callback: Callback\<OnPageVisibleEvent\>)
4636e41f4b71Sopenharmony_ci
4637e41f4b71Sopenharmony_ciCalled when the old page is not displayed and the new page is about to be visible.
4638e41f4b71Sopenharmony_ci
4639e41f4b71Sopenharmony_ciFor details about the component lifecycle, see [Lifecycle of Web Components](../../web/web-event-sequence.md).
4640e41f4b71Sopenharmony_ci
4641e41f4b71Sopenharmony_ci**Parameters**
4642e41f4b71Sopenharmony_ci
4643e41f4b71Sopenharmony_ci| Name | Type  | Description                      |
4644e41f4b71Sopenharmony_ci| ---- | ------ | -------------------------- |
4645e41f4b71Sopenharmony_ci| callback  | Callback\<[OnPageVisibleEvent](#onpagevisibleevent12)\> | Callback invoked when the old page is not displayed and the new page is about to be visible.|
4646e41f4b71Sopenharmony_ci
4647e41f4b71Sopenharmony_ci**Example**
4648e41f4b71Sopenharmony_ci
4649e41f4b71Sopenharmony_ci  ```ts
4650e41f4b71Sopenharmony_ci  // xxx.ets
4651e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4652e41f4b71Sopenharmony_ci
4653e41f4b71Sopenharmony_ci  @Entry
4654e41f4b71Sopenharmony_ci  @Component
4655e41f4b71Sopenharmony_ci  struct WebComponent {
4656e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4657e41f4b71Sopenharmony_ci
4658e41f4b71Sopenharmony_ci    build() {
4659e41f4b71Sopenharmony_ci      Column() {
4660e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4661e41f4b71Sopenharmony_ci          .onPageVisible((event) => {
4662e41f4b71Sopenharmony_ci            console.log('onPageVisible url:' + event.url);
4663e41f4b71Sopenharmony_ci          })
4664e41f4b71Sopenharmony_ci      }
4665e41f4b71Sopenharmony_ci    }
4666e41f4b71Sopenharmony_ci  }
4667e41f4b71Sopenharmony_ci  ```
4668e41f4b71Sopenharmony_ci
4669e41f4b71Sopenharmony_ci### onInterceptKeyEvent<sup>9+</sup>
4670e41f4b71Sopenharmony_ci
4671e41f4b71Sopenharmony_cionInterceptKeyEvent(callback: (event: KeyEvent) => boolean)
4672e41f4b71Sopenharmony_ci
4673e41f4b71Sopenharmony_ciCalled when the key event is intercepted and before it is consumed by the webview.
4674e41f4b71Sopenharmony_ci
4675e41f4b71Sopenharmony_ci**Parameters**
4676e41f4b71Sopenharmony_ci
4677e41f4b71Sopenharmony_ci| Name  | Type                                    | Description          |
4678e41f4b71Sopenharmony_ci| ----- | ---------------------------------------- | -------------- |
4679e41f4b71Sopenharmony_ci| event | [KeyEvent](../apis-arkui/arkui-ts/ts-universal-events-key.md#keyevent) | Key event that is triggered.|
4680e41f4b71Sopenharmony_ci
4681e41f4b71Sopenharmony_ci**Return value**
4682e41f4b71Sopenharmony_ci
4683e41f4b71Sopenharmony_ci| Type     | Description                                      |
4684e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- |
4685e41f4b71Sopenharmony_ci| boolean | Whether to continue to transfer the key event to the webview kernel.|
4686e41f4b71Sopenharmony_ci
4687e41f4b71Sopenharmony_ci**Example**
4688e41f4b71Sopenharmony_ci
4689e41f4b71Sopenharmony_ci  ```ts
4690e41f4b71Sopenharmony_ci  // xxx.ets
4691e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4692e41f4b71Sopenharmony_ci
4693e41f4b71Sopenharmony_ci  @Entry
4694e41f4b71Sopenharmony_ci  @Component
4695e41f4b71Sopenharmony_ci  struct WebComponent {
4696e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4697e41f4b71Sopenharmony_ci
4698e41f4b71Sopenharmony_ci    build() {
4699e41f4b71Sopenharmony_ci      Column() {
4700e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4701e41f4b71Sopenharmony_ci          .onInterceptKeyEvent((event) => {
4702e41f4b71Sopenharmony_ci            if (event.keyCode == 2017 || event.keyCode == 2018) {
4703e41f4b71Sopenharmony_ci              console.info(`onInterceptKeyEvent get event.keyCode ${event.keyCode}`);
4704e41f4b71Sopenharmony_ci              return true;
4705e41f4b71Sopenharmony_ci            }
4706e41f4b71Sopenharmony_ci            return false;
4707e41f4b71Sopenharmony_ci          })
4708e41f4b71Sopenharmony_ci      }
4709e41f4b71Sopenharmony_ci    }
4710e41f4b71Sopenharmony_ci  }
4711e41f4b71Sopenharmony_ci  ```
4712e41f4b71Sopenharmony_ci
4713e41f4b71Sopenharmony_ci### onTouchIconUrlReceived<sup>9+</sup>
4714e41f4b71Sopenharmony_ci
4715e41f4b71Sopenharmony_cionTouchIconUrlReceived(callback: Callback\<OnTouchIconUrlReceivedEvent\>)
4716e41f4b71Sopenharmony_ci
4717e41f4b71Sopenharmony_ciCalled when an apple-touch-icon URL is received.
4718e41f4b71Sopenharmony_ci
4719e41f4b71Sopenharmony_ci**Parameters**
4720e41f4b71Sopenharmony_ci
4721e41f4b71Sopenharmony_ci| Name        | Type   | Description                       |
4722e41f4b71Sopenharmony_ci| ----------- | ------- | --------------------------- |
4723e41f4b71Sopenharmony_ci| callback         | Callback\<[OnTouchIconUrlReceivedEvent](#ontouchiconurlreceivedevent12)\>  | Callback invoked when an apple-touch-icon URL is received.|
4724e41f4b71Sopenharmony_ci
4725e41f4b71Sopenharmony_ci**Example**
4726e41f4b71Sopenharmony_ci
4727e41f4b71Sopenharmony_ci  ```ts
4728e41f4b71Sopenharmony_ci  // xxx.ets
4729e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4730e41f4b71Sopenharmony_ci
4731e41f4b71Sopenharmony_ci  @Entry
4732e41f4b71Sopenharmony_ci  @Component
4733e41f4b71Sopenharmony_ci  struct WebComponent {
4734e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4735e41f4b71Sopenharmony_ci
4736e41f4b71Sopenharmony_ci    build() {
4737e41f4b71Sopenharmony_ci      Column() {
4738e41f4b71Sopenharmony_ci        Web({ src: 'www.baidu.com', controller: this.controller })
4739e41f4b71Sopenharmony_ci          .onTouchIconUrlReceived((event) => {
4740e41f4b71Sopenharmony_ci            console.log('onTouchIconUrlReceived:' + JSON.stringify(event));
4741e41f4b71Sopenharmony_ci          })
4742e41f4b71Sopenharmony_ci      }
4743e41f4b71Sopenharmony_ci    }
4744e41f4b71Sopenharmony_ci  }
4745e41f4b71Sopenharmony_ci  ```
4746e41f4b71Sopenharmony_ci
4747e41f4b71Sopenharmony_ci### onFaviconReceived<sup>9+</sup>
4748e41f4b71Sopenharmony_ci
4749e41f4b71Sopenharmony_cionFaviconReceived(callback: Callback\<OnFaviconReceivedEvent\>)
4750e41f4b71Sopenharmony_ci
4751e41f4b71Sopenharmony_ciCalled when this web page receives a new favicon.
4752e41f4b71Sopenharmony_ci
4753e41f4b71Sopenharmony_ci**Parameters**
4754e41f4b71Sopenharmony_ci
4755e41f4b71Sopenharmony_ci| Name    | Type                                    | Description                     |
4756e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | ------------------------- |
4757e41f4b71Sopenharmony_ci| callback | Callback\<[OnFaviconReceivedEvent](#onfaviconreceivedevent12)\> | Callback invoked when the current web page receives a new favicon.|
4758e41f4b71Sopenharmony_ci
4759e41f4b71Sopenharmony_ci**Example**
4760e41f4b71Sopenharmony_ci
4761e41f4b71Sopenharmony_ci  ```ts
4762e41f4b71Sopenharmony_ci  // xxx.ets
4763e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4764e41f4b71Sopenharmony_ci  import { image } from '@kit.ImageKit';
4765e41f4b71Sopenharmony_ci
4766e41f4b71Sopenharmony_ci  @Entry
4767e41f4b71Sopenharmony_ci  @Component
4768e41f4b71Sopenharmony_ci  struct WebComponent {
4769e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4770e41f4b71Sopenharmony_ci    @State icon: image.PixelMap | undefined = undefined;
4771e41f4b71Sopenharmony_ci
4772e41f4b71Sopenharmony_ci    build() {
4773e41f4b71Sopenharmony_ci      Column() {
4774e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4775e41f4b71Sopenharmony_ci          .onFaviconReceived((event) => {
4776e41f4b71Sopenharmony_ci            console.log('onFaviconReceived');
4777e41f4b71Sopenharmony_ci            this.icon = event.favicon;
4778e41f4b71Sopenharmony_ci          })
4779e41f4b71Sopenharmony_ci      }
4780e41f4b71Sopenharmony_ci    }
4781e41f4b71Sopenharmony_ci  }
4782e41f4b71Sopenharmony_ci  ```
4783e41f4b71Sopenharmony_ci
4784e41f4b71Sopenharmony_ci### onAudioStateChanged<sup>10+</sup>
4785e41f4b71Sopenharmony_ci
4786e41f4b71Sopenharmony_cionAudioStateChanged(callback: Callback\<OnAudioStateChangedEvent\>)
4787e41f4b71Sopenharmony_ci
4788e41f4b71Sopenharmony_ciCalled when the audio playback status on the web page changes.
4789e41f4b71Sopenharmony_ci
4790e41f4b71Sopenharmony_ci**Parameters**
4791e41f4b71Sopenharmony_ci
4792e41f4b71Sopenharmony_ci| Name    | Type   | Description                              |
4793e41f4b71Sopenharmony_ci| ------- | ------- | ---------------------------------- |
4794e41f4b71Sopenharmony_ci| callback | Callback\<[OnAudioStateChangedEvent](#onaudiostatechangedevent12)\> | Callback invoked when the audio playback status on the web page changes.|
4795e41f4b71Sopenharmony_ci
4796e41f4b71Sopenharmony_ci**Example**
4797e41f4b71Sopenharmony_ci
4798e41f4b71Sopenharmony_ci  ```ts
4799e41f4b71Sopenharmony_ci  // xxx.ets
4800e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4801e41f4b71Sopenharmony_ci
4802e41f4b71Sopenharmony_ci  @Entry
4803e41f4b71Sopenharmony_ci  @Component
4804e41f4b71Sopenharmony_ci  struct WebComponent {
4805e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4806e41f4b71Sopenharmony_ci    @State playing: boolean = false;
4807e41f4b71Sopenharmony_ci
4808e41f4b71Sopenharmony_ci    build() {
4809e41f4b71Sopenharmony_ci      Column() {
4810e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4811e41f4b71Sopenharmony_ci          .onAudioStateChanged(event => {
4812e41f4b71Sopenharmony_ci            this.playing = event.playing;
4813e41f4b71Sopenharmony_ci            console.debug('onAudioStateChanged playing: ' + this.playing);
4814e41f4b71Sopenharmony_ci          })
4815e41f4b71Sopenharmony_ci      }
4816e41f4b71Sopenharmony_ci    }
4817e41f4b71Sopenharmony_ci  }
4818e41f4b71Sopenharmony_ci  ```
4819e41f4b71Sopenharmony_ci
4820e41f4b71Sopenharmony_ci### onFirstContentfulPaint<sup>10+</sup>
4821e41f4b71Sopenharmony_ci
4822e41f4b71Sopenharmony_ci onFirstContentfulPaint(callback: Callback\<OnFirstContentfulPaintEvent\>)
4823e41f4b71Sopenharmony_ci
4824e41f4b71Sopenharmony_ciCalled when the first content paint occurs on the web page.
4825e41f4b71Sopenharmony_ci
4826e41f4b71Sopenharmony_ci**Parameters**
4827e41f4b71Sopenharmony_ci
4828e41f4b71Sopenharmony_ci| Name                   | Type  | Description                             |
4829e41f4b71Sopenharmony_ci| ---------------------- | ------ | --------------------------------- |
4830e41f4b71Sopenharmony_ci| callback    | Callback\<[OnFirstContentfulPaintEvent](#onfirstcontentfulpaintevent12)\> | Callback invoked when the first content paint occurs on the web page.         |
4831e41f4b71Sopenharmony_ci
4832e41f4b71Sopenharmony_ci**Example**
4833e41f4b71Sopenharmony_ci
4834e41f4b71Sopenharmony_ci  ```ts
4835e41f4b71Sopenharmony_ci  // xxx.ets
4836e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4837e41f4b71Sopenharmony_ci
4838e41f4b71Sopenharmony_ci  @Entry
4839e41f4b71Sopenharmony_ci  @Component
4840e41f4b71Sopenharmony_ci  struct WebComponent {
4841e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4842e41f4b71Sopenharmony_ci
4843e41f4b71Sopenharmony_ci    build() {
4844e41f4b71Sopenharmony_ci      Column() {
4845e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4846e41f4b71Sopenharmony_ci          .onFirstContentfulPaint(event => {
4847e41f4b71Sopenharmony_ci            if (event) {
4848e41f4b71Sopenharmony_ci              console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
4849e41f4b71Sopenharmony_ci              event.navigationStartTick + ", [firstContentfulPaintMs]:" +
4850e41f4b71Sopenharmony_ci              event.firstContentfulPaintMs);
4851e41f4b71Sopenharmony_ci            }
4852e41f4b71Sopenharmony_ci          })
4853e41f4b71Sopenharmony_ci      }
4854e41f4b71Sopenharmony_ci    }
4855e41f4b71Sopenharmony_ci  }
4856e41f4b71Sopenharmony_ci  ```
4857e41f4b71Sopenharmony_ci
4858e41f4b71Sopenharmony_ci### onFirstMeaningfulPaint<sup>12+</sup>
4859e41f4b71Sopenharmony_ci
4860e41f4b71Sopenharmony_cionFirstMeaningfulPaint(callback: [OnFirstMeaningfulPaintCallback](#onfirstmeaningfulpaintcallback12))
4861e41f4b71Sopenharmony_ci
4862e41f4b71Sopenharmony_ciCalled when the first meaningful paint occurs on the web page.
4863e41f4b71Sopenharmony_ci
4864e41f4b71Sopenharmony_ci**Parameters**
4865e41f4b71Sopenharmony_ci
4866e41f4b71Sopenharmony_ci| Name  | Type                                                        | Description                                  |
4867e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | -------------------------------------- |
4868e41f4b71Sopenharmony_ci| callback | [OnFirstMeaningfulPaintCallback](#onfirstmeaningfulpaintcallback12) | Callback invoked when the First Meaningful Paint occurs on the web page.|
4869e41f4b71Sopenharmony_ci
4870e41f4b71Sopenharmony_ci**Example**
4871e41f4b71Sopenharmony_ci
4872e41f4b71Sopenharmony_ci  ```ts
4873e41f4b71Sopenharmony_ci  // xxx.ets
4874e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4875e41f4b71Sopenharmony_ci
4876e41f4b71Sopenharmony_ci  @Entry
4877e41f4b71Sopenharmony_ci  @Component
4878e41f4b71Sopenharmony_ci  struct WebComponent {
4879e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4880e41f4b71Sopenharmony_ci
4881e41f4b71Sopenharmony_ci    build() {
4882e41f4b71Sopenharmony_ci      Column() {
4883e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4884e41f4b71Sopenharmony_ci          .onFirstMeaningfulPaint((details) => {
4885e41f4b71Sopenharmony_ci            console.log("onFirstMeaningfulPaint: [navigationStartTime]= " + details.navigationStartTime +
4886e41f4b71Sopenharmony_ci              ", [firstMeaningfulPaintTime]=" + details.firstMeaningfulPaintTime);
4887e41f4b71Sopenharmony_ci          })
4888e41f4b71Sopenharmony_ci      }
4889e41f4b71Sopenharmony_ci    }
4890e41f4b71Sopenharmony_ci  }
4891e41f4b71Sopenharmony_ci  ```
4892e41f4b71Sopenharmony_ci
4893e41f4b71Sopenharmony_ci### onLargestContentfulPaint<sup>12+</sup>
4894e41f4b71Sopenharmony_ci
4895e41f4b71Sopenharmony_cionLargestContentfulPaint(callback: [OnLargestContentfulPaintCallback](#onlargestcontentfulpaintcallback12))
4896e41f4b71Sopenharmony_ci
4897e41f4b71Sopenharmony_ciCalled when the largest content paint occurs on the web page.
4898e41f4b71Sopenharmony_ci
4899e41f4b71Sopenharmony_ci**Parameters**
4900e41f4b71Sopenharmony_ci
4901e41f4b71Sopenharmony_ci| Name  | Type                                                        | Description                                |
4902e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ------------------------------------ |
4903e41f4b71Sopenharmony_ci| callback | [OnLargestContentfulPaintCallback](#onlargestcontentfulpaintcallback12) | Callback invoked when the largest content paint occurs on the web page.|
4904e41f4b71Sopenharmony_ci
4905e41f4b71Sopenharmony_ci**Example**
4906e41f4b71Sopenharmony_ci
4907e41f4b71Sopenharmony_ci  ```ts
4908e41f4b71Sopenharmony_ci  // xxx.ets
4909e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4910e41f4b71Sopenharmony_ci
4911e41f4b71Sopenharmony_ci  @Entry
4912e41f4b71Sopenharmony_ci  @Component
4913e41f4b71Sopenharmony_ci  struct WebComponent {
4914e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4915e41f4b71Sopenharmony_ci
4916e41f4b71Sopenharmony_ci    build() {
4917e41f4b71Sopenharmony_ci      Column() {
4918e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4919e41f4b71Sopenharmony_ci          .onLargestContentfulPaint((details) => {
4920e41f4b71Sopenharmony_ci            console.log("onLargestContentfulPaint: [navigationStartTime]= " + details.navigationStartTime +
4921e41f4b71Sopenharmony_ci              ", [largestImagePaintTime]=" + details.largestImagePaintTime +
4922e41f4b71Sopenharmony_ci              ", [largestTextPaintTime]=" + details.largestTextPaintTime +
4923e41f4b71Sopenharmony_ci              ", [largestImageLoadStartTime]=" + details.largestImageLoadStartTime +
4924e41f4b71Sopenharmony_ci              ", [largestImageLoadEndTime]=" + details.largestImageLoadEndTime +
4925e41f4b71Sopenharmony_ci              ", [imageBPP]=" + details.imageBPP);
4926e41f4b71Sopenharmony_ci          })
4927e41f4b71Sopenharmony_ci      }
4928e41f4b71Sopenharmony_ci    }
4929e41f4b71Sopenharmony_ci  }
4930e41f4b71Sopenharmony_ci  ```
4931e41f4b71Sopenharmony_ci
4932e41f4b71Sopenharmony_ci### onLoadIntercept<sup>10+</sup>
4933e41f4b71Sopenharmony_ci
4934e41f4b71Sopenharmony_cionLoadIntercept(callback: Callback\<OnLoadInterceptEvent, boolean\>)
4935e41f4b71Sopenharmony_ci
4936e41f4b71Sopenharmony_ciCalled when the **Web** component is about to access a URL. This API is used to determine whether to block the access, which is allowed by default.
4937e41f4b71Sopenharmony_ci
4938e41f4b71Sopenharmony_ci**Parameters**
4939e41f4b71Sopenharmony_ci
4940e41f4b71Sopenharmony_ci| Name    | Type                                    | Description       |
4941e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | ----------- |
4942e41f4b71Sopenharmony_ci| callback | Callback\<[OnLoadInterceptEvent](#onloadinterceptevent12), boolean\> | Callback invoked when the **Web** component is about to access a URL.<br>Return value: boolean<br> Returns **true** if the access is blocked; returns **false** otherwise.|
4943e41f4b71Sopenharmony_ci
4944e41f4b71Sopenharmony_ci**Example**
4945e41f4b71Sopenharmony_ci
4946e41f4b71Sopenharmony_ci  ```ts
4947e41f4b71Sopenharmony_ci  // xxx.ets
4948e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4949e41f4b71Sopenharmony_ci
4950e41f4b71Sopenharmony_ci  @Entry
4951e41f4b71Sopenharmony_ci  @Component
4952e41f4b71Sopenharmony_ci  struct WebComponent {
4953e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4954e41f4b71Sopenharmony_ci
4955e41f4b71Sopenharmony_ci    build() {
4956e41f4b71Sopenharmony_ci      Column() {
4957e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4958e41f4b71Sopenharmony_ci          .onLoadIntercept((event) => {
4959e41f4b71Sopenharmony_ci            console.log('url:' + event.data.getRequestUrl());
4960e41f4b71Sopenharmony_ci            console.log('isMainFrame:' + event.data.isMainFrame());
4961e41f4b71Sopenharmony_ci            console.log('isRedirect:' + event.data.isRedirect());
4962e41f4b71Sopenharmony_ci            console.log('isRequestGesture:' + event.data.isRequestGesture());
4963e41f4b71Sopenharmony_ci            return true;
4964e41f4b71Sopenharmony_ci          })
4965e41f4b71Sopenharmony_ci      }
4966e41f4b71Sopenharmony_ci    }
4967e41f4b71Sopenharmony_ci  }
4968e41f4b71Sopenharmony_ci  ```
4969e41f4b71Sopenharmony_ci
4970e41f4b71Sopenharmony_ci### onRequestSelected
4971e41f4b71Sopenharmony_ci
4972e41f4b71Sopenharmony_cionRequestSelected(callback: () => void)
4973e41f4b71Sopenharmony_ci
4974e41f4b71Sopenharmony_ciCalled when the **Web** component obtains the focus.
4975e41f4b71Sopenharmony_ci
4976e41f4b71Sopenharmony_ci**Example**
4977e41f4b71Sopenharmony_ci
4978e41f4b71Sopenharmony_ci  ```ts
4979e41f4b71Sopenharmony_ci  // xxx.ets
4980e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
4981e41f4b71Sopenharmony_ci
4982e41f4b71Sopenharmony_ci  @Entry
4983e41f4b71Sopenharmony_ci  @Component
4984e41f4b71Sopenharmony_ci  struct WebComponent {
4985e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
4986e41f4b71Sopenharmony_ci
4987e41f4b71Sopenharmony_ci    build() {
4988e41f4b71Sopenharmony_ci      Column() {
4989e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
4990e41f4b71Sopenharmony_ci          .onRequestSelected(() => {
4991e41f4b71Sopenharmony_ci            console.log('onRequestSelected');
4992e41f4b71Sopenharmony_ci          })
4993e41f4b71Sopenharmony_ci      }
4994e41f4b71Sopenharmony_ci    }
4995e41f4b71Sopenharmony_ci  }
4996e41f4b71Sopenharmony_ci  ```
4997e41f4b71Sopenharmony_ci### onScreenCaptureRequest<sup>10+</sup>
4998e41f4b71Sopenharmony_ci
4999e41f4b71Sopenharmony_cionScreenCaptureRequest(callback: Callback\<OnScreenCaptureRequestEvent\>)
5000e41f4b71Sopenharmony_ci
5001e41f4b71Sopenharmony_ciCalled when a screen capture request is received.
5002e41f4b71Sopenharmony_ci
5003e41f4b71Sopenharmony_ci**Parameters**
5004e41f4b71Sopenharmony_ci
5005e41f4b71Sopenharmony_ci| Name    | Type                                    | Description          |
5006e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | -------------- |
5007e41f4b71Sopenharmony_ci| callback | Callback\<[OnScreenCaptureRequestEvent](#onscreencapturerequestevent12)\> | Called when a screen capture request is received.|
5008e41f4b71Sopenharmony_ci
5009e41f4b71Sopenharmony_ci**Example**
5010e41f4b71Sopenharmony_ci
5011e41f4b71Sopenharmony_ci  ```ts
5012e41f4b71Sopenharmony_ci  // xxx.ets
5013e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5014e41f4b71Sopenharmony_ci
5015e41f4b71Sopenharmony_ci  @Entry
5016e41f4b71Sopenharmony_ci  @Component
5017e41f4b71Sopenharmony_ci  struct WebComponent {
5018e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5019e41f4b71Sopenharmony_ci
5020e41f4b71Sopenharmony_ci    build() {
5021e41f4b71Sopenharmony_ci      Column() {
5022e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
5023e41f4b71Sopenharmony_ci          .onScreenCaptureRequest((event) => {
5024e41f4b71Sopenharmony_ci            if (event) {
5025e41f4b71Sopenharmony_ci              AlertDialog.show({
5026e41f4b71Sopenharmony_ci                title: 'title: ' + event.handler.getOrigin(),
5027e41f4b71Sopenharmony_ci                message: 'text',
5028e41f4b71Sopenharmony_ci                primaryButton: {
5029e41f4b71Sopenharmony_ci                  value: 'deny',
5030e41f4b71Sopenharmony_ci                  action: () => {
5031e41f4b71Sopenharmony_ci                    event.handler.deny();
5032e41f4b71Sopenharmony_ci                  }
5033e41f4b71Sopenharmony_ci                },
5034e41f4b71Sopenharmony_ci                secondaryButton: {
5035e41f4b71Sopenharmony_ci                  value: 'onConfirm',
5036e41f4b71Sopenharmony_ci                  action: () => {
5037e41f4b71Sopenharmony_ci                    event.handler.grant({ captureMode: WebCaptureMode.HOME_SCREEN });
5038e41f4b71Sopenharmony_ci                  }
5039e41f4b71Sopenharmony_ci                },
5040e41f4b71Sopenharmony_ci                cancel: () => {
5041e41f4b71Sopenharmony_ci                  event.handler.deny();
5042e41f4b71Sopenharmony_ci                }
5043e41f4b71Sopenharmony_ci              })
5044e41f4b71Sopenharmony_ci            }
5045e41f4b71Sopenharmony_ci          })
5046e41f4b71Sopenharmony_ci      }
5047e41f4b71Sopenharmony_ci    }
5048e41f4b71Sopenharmony_ci  }
5049e41f4b71Sopenharmony_ci  ```
5050e41f4b71Sopenharmony_ci
5051e41f4b71Sopenharmony_ci### onOverScroll<sup>10+</sup>
5052e41f4b71Sopenharmony_ci
5053e41f4b71Sopenharmony_cionOverScroll(callback: Callback\<OnOverScrollEvent\>)
5054e41f4b71Sopenharmony_ci
5055e41f4b71Sopenharmony_ciCalled when the web page is overscrolled. It is used to notify the user of the offset of the overscroll.
5056e41f4b71Sopenharmony_ci
5057e41f4b71Sopenharmony_ci**Parameters**
5058e41f4b71Sopenharmony_ci
5059e41f4b71Sopenharmony_ci| Name    | Type  | Description               |
5060e41f4b71Sopenharmony_ci| ------- | ------ | ------------------- |
5061e41f4b71Sopenharmony_ci| callback | Callback\<[OnOverScrollEvent](#onoverscrollevent12)\> | Callback invoked when the web page is overscrolled.|
5062e41f4b71Sopenharmony_ci
5063e41f4b71Sopenharmony_ci**Example**
5064e41f4b71Sopenharmony_ci
5065e41f4b71Sopenharmony_ci  ```ts
5066e41f4b71Sopenharmony_ci  // xxx.ets
5067e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5068e41f4b71Sopenharmony_ci
5069e41f4b71Sopenharmony_ci  @Entry
5070e41f4b71Sopenharmony_ci  @Component
5071e41f4b71Sopenharmony_ci  struct WebComponent {
5072e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5073e41f4b71Sopenharmony_ci
5074e41f4b71Sopenharmony_ci    build() {
5075e41f4b71Sopenharmony_ci      Column() {
5076e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
5077e41f4b71Sopenharmony_ci          .onOverScroll((event) => {
5078e41f4b71Sopenharmony_ci            console.info("x = " + event.xOffset);
5079e41f4b71Sopenharmony_ci            console.info("y = " + event.yOffset);
5080e41f4b71Sopenharmony_ci          })
5081e41f4b71Sopenharmony_ci      }
5082e41f4b71Sopenharmony_ci    }
5083e41f4b71Sopenharmony_ci  }
5084e41f4b71Sopenharmony_ci  ```
5085e41f4b71Sopenharmony_ci
5086e41f4b71Sopenharmony_ci### onControllerAttached<sup>10+</sup>
5087e41f4b71Sopenharmony_ci
5088e41f4b71Sopenharmony_cionControllerAttached(callback: () => void)
5089e41f4b71Sopenharmony_ci
5090e41f4b71Sopenharmony_ciCalled when the controller is successfully bound to the **Web** component. The controller must be WebviewController.
5091e41f4b71Sopenharmony_ciAs the web page is not yet loaded when this callback is called, APIs for operating the web page, for example, [zoomIn](js-apis-webview.md#zoomin) and [zoomOut](js-apis-webview.md#zoomout), cannot be used in the callback. Other APIs, such as [loadUrl](js-apis-webview.md#loadurl) and [getWebId](js-apis-webview.md#getwebid), which do not involve web page operations, can be used properly.
5092e41f4b71Sopenharmony_ci
5093e41f4b71Sopenharmony_ciFor details about the component lifecycle, see [Lifecycle of Web Components](../../web/web-event-sequence.md).
5094e41f4b71Sopenharmony_ci
5095e41f4b71Sopenharmony_ci**Example**
5096e41f4b71Sopenharmony_ci
5097e41f4b71Sopenharmony_ciThe following example uses **loadUrl** in the callback to load the web page.
5098e41f4b71Sopenharmony_ci  ```ts
5099e41f4b71Sopenharmony_ci  // xxx.ets
5100e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5101e41f4b71Sopenharmony_ci
5102e41f4b71Sopenharmony_ci  @Entry
5103e41f4b71Sopenharmony_ci  @Component
5104e41f4b71Sopenharmony_ci  struct WebComponent {
5105e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5106e41f4b71Sopenharmony_ci
5107e41f4b71Sopenharmony_ci    build() {
5108e41f4b71Sopenharmony_ci      Column() {
5109e41f4b71Sopenharmony_ci        Web({ src: '', controller: this.controller })
5110e41f4b71Sopenharmony_ci          .onControllerAttached(() => {
5111e41f4b71Sopenharmony_ci            this.controller.loadUrl($rawfile("index.html"));
5112e41f4b71Sopenharmony_ci          })
5113e41f4b71Sopenharmony_ci      }
5114e41f4b71Sopenharmony_ci    }
5115e41f4b71Sopenharmony_ci  }
5116e41f4b71Sopenharmony_ci  ```
5117e41f4b71Sopenharmony_ci
5118e41f4b71Sopenharmony_ciThe following example uses **getWebId** in the callback
5119e41f4b71Sopenharmony_ci  ```ts
5120e41f4b71Sopenharmony_ci  // xxx.ets
5121e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5122e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
5123e41f4b71Sopenharmony_ci
5124e41f4b71Sopenharmony_ci  @Entry
5125e41f4b71Sopenharmony_ci  @Component
5126e41f4b71Sopenharmony_ci  struct WebComponent {
5127e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5128e41f4b71Sopenharmony_ci
5129e41f4b71Sopenharmony_ci    build() {
5130e41f4b71Sopenharmony_ci      Column() {
5131e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
5132e41f4b71Sopenharmony_ci          .onControllerAttached(() => {
5133e41f4b71Sopenharmony_ci            try {
5134e41f4b71Sopenharmony_ci              let id = this.controller.getWebId();
5135e41f4b71Sopenharmony_ci              console.log("id: " + id);
5136e41f4b71Sopenharmony_ci            } catch (error) {
5137e41f4b71Sopenharmony_ci              let code = (error as BusinessError).code;
5138e41f4b71Sopenharmony_ci              let message = (error as BusinessError).message;
5139e41f4b71Sopenharmony_ci              console.error(`ErrorCode: ${code},  Message: ${message}`);
5140e41f4b71Sopenharmony_ci            }
5141e41f4b71Sopenharmony_ci          })
5142e41f4b71Sopenharmony_ci      }
5143e41f4b71Sopenharmony_ci    }
5144e41f4b71Sopenharmony_ci  }
5145e41f4b71Sopenharmony_ci  ```
5146e41f4b71Sopenharmony_ci  HTML file to be loaded:
5147e41f4b71Sopenharmony_ci  ```html
5148e41f4b71Sopenharmony_ci  <!-- index.html -->
5149e41f4b71Sopenharmony_ci  <!DOCTYPE html>
5150e41f4b71Sopenharmony_ci  <html>
5151e41f4b71Sopenharmony_ci      <body>
5152e41f4b71Sopenharmony_ci          <p>Hello World</p>
5153e41f4b71Sopenharmony_ci      </body>
5154e41f4b71Sopenharmony_ci  </html>
5155e41f4b71Sopenharmony_ci  ```
5156e41f4b71Sopenharmony_ci
5157e41f4b71Sopenharmony_ci### onNavigationEntryCommitted<sup>11+</sup>
5158e41f4b71Sopenharmony_ci
5159e41f4b71Sopenharmony_cionNavigationEntryCommitted(callback: [OnNavigationEntryCommittedCallback](#onnavigationentrycommittedcallback11))
5160e41f4b71Sopenharmony_ci
5161e41f4b71Sopenharmony_ciCalled when a web page redirection request is submitted.
5162e41f4b71Sopenharmony_ci
5163e41f4b71Sopenharmony_ci**Parameters**
5164e41f4b71Sopenharmony_ci
5165e41f4b71Sopenharmony_ci| Name         | Type                                                                        | Description                   |
5166e41f4b71Sopenharmony_ci| -------------- | --------------------------------------------------------------------------- | ---------------------- |
5167e41f4b71Sopenharmony_ci| callback       | [OnNavigationEntryCommittedCallback](#onnavigationentrycommittedcallback11) | Callback invoked when a web page redirection request is submitted.|
5168e41f4b71Sopenharmony_ci
5169e41f4b71Sopenharmony_ci**Example**
5170e41f4b71Sopenharmony_ci
5171e41f4b71Sopenharmony_ci  ```ts
5172e41f4b71Sopenharmony_ci  // xxx.ets
5173e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5174e41f4b71Sopenharmony_ci
5175e41f4b71Sopenharmony_ci  @Entry
5176e41f4b71Sopenharmony_ci  @Component
5177e41f4b71Sopenharmony_ci  struct WebComponent {
5178e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5179e41f4b71Sopenharmony_ci
5180e41f4b71Sopenharmony_ci    build() {
5181e41f4b71Sopenharmony_ci      Column() {
5182e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
5183e41f4b71Sopenharmony_ci          .onNavigationEntryCommitted((details) => {
5184e41f4b71Sopenharmony_ci            console.log("onNavigationEntryCommitted: [isMainFrame]= " + details.isMainFrame +
5185e41f4b71Sopenharmony_ci              ", [isSameDocument]=" + details.isSameDocument +
5186e41f4b71Sopenharmony_ci              ", [didReplaceEntry]=" + details.didReplaceEntry +
5187e41f4b71Sopenharmony_ci              ", [navigationType]=" + details.navigationType +
5188e41f4b71Sopenharmony_ci              ", [url]=" + details.url);
5189e41f4b71Sopenharmony_ci          })
5190e41f4b71Sopenharmony_ci      }
5191e41f4b71Sopenharmony_ci    }
5192e41f4b71Sopenharmony_ci  }
5193e41f4b71Sopenharmony_ci  ```
5194e41f4b71Sopenharmony_ci
5195e41f4b71Sopenharmony_ci### onSafeBrowsingCheckResult<sup>11+</sup>
5196e41f4b71Sopenharmony_ci
5197e41f4b71Sopenharmony_cionSafeBrowsingCheckResult(callback: OnSafeBrowsingCheckResultCallback)
5198e41f4b71Sopenharmony_ci
5199e41f4b71Sopenharmony_ciCalled when the safe browsing check result is received.
5200e41f4b71Sopenharmony_ci
5201e41f4b71Sopenharmony_ci**Parameters**
5202e41f4b71Sopenharmony_ci
5203e41f4b71Sopenharmony_ci| Name    | Type                                                                      | Description                   |
5204e41f4b71Sopenharmony_ci| ----------| --------------------------------------------------------------------------| ---------------------- |
5205e41f4b71Sopenharmony_ci| callback  | [OnSafeBrowsingCheckResultCallback](#onsafebrowsingcheckresultcallback11) | Called when the safe browsing check result is received.|
5206e41f4b71Sopenharmony_ci
5207e41f4b71Sopenharmony_ci**Example**
5208e41f4b71Sopenharmony_ci
5209e41f4b71Sopenharmony_ci  ```ts
5210e41f4b71Sopenharmony_ci  // xxx.ets
5211e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5212e41f4b71Sopenharmony_ci
5213e41f4b71Sopenharmony_ci  export enum ThreatType {
5214e41f4b71Sopenharmony_ci    UNKNOWN = -1,
5215e41f4b71Sopenharmony_ci    THREAT_ILLEGAL = 0,
5216e41f4b71Sopenharmony_ci    THREAT_FRAUD = 1,
5217e41f4b71Sopenharmony_ci    THREAT_RISK = 2,
5218e41f4b71Sopenharmony_ci    THREAT_WARNING = 3,
5219e41f4b71Sopenharmony_ci  }
5220e41f4b71Sopenharmony_ci
5221e41f4b71Sopenharmony_ci  export class OnSafeBrowsingCheckResultCallback {
5222e41f4b71Sopenharmony_ci    threatType: ThreatType = ThreatType.UNKNOWN;
5223e41f4b71Sopenharmony_ci  }
5224e41f4b71Sopenharmony_ci
5225e41f4b71Sopenharmony_ci  @Entry
5226e41f4b71Sopenharmony_ci  @Component
5227e41f4b71Sopenharmony_ci  struct WebComponent {
5228e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5229e41f4b71Sopenharmony_ci
5230e41f4b71Sopenharmony_ci    build() {
5231e41f4b71Sopenharmony_ci      Column() {
5232e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
5233e41f4b71Sopenharmony_ci          .onSafeBrowsingCheckResult((callback) => {
5234e41f4b71Sopenharmony_ci            let jsonData = JSON.stringify(callback);
5235e41f4b71Sopenharmony_ci            let json: OnSafeBrowsingCheckResultCallback = JSON.parse(jsonData);
5236e41f4b71Sopenharmony_ci            console.log("onSafeBrowsingCheckResult: [threatType]= " + json.threatType);
5237e41f4b71Sopenharmony_ci          })
5238e41f4b71Sopenharmony_ci      }
5239e41f4b71Sopenharmony_ci    }
5240e41f4b71Sopenharmony_ci  }
5241e41f4b71Sopenharmony_ci  ```
5242e41f4b71Sopenharmony_ci
5243e41f4b71Sopenharmony_ci### onNativeEmbedLifecycleChange<sup>11+</sup>
5244e41f4b71Sopenharmony_ci
5245e41f4b71Sopenharmony_cionNativeEmbedLifecycleChange(callback: NativeEmbedDataInfo)
5246e41f4b71Sopenharmony_ci
5247e41f4b71Sopenharmony_ciCalled when the lifecycle of the Embed tag changes.
5248e41f4b71Sopenharmony_ci
5249e41f4b71Sopenharmony_ci**Parameters**
5250e41f4b71Sopenharmony_ci
5251e41f4b71Sopenharmony_ci| Name         | Type                                                                        | Description                   |
5252e41f4b71Sopenharmony_ci| -------------- | --------------------------------------------------------------------------- | ---------------------- |
5253e41f4b71Sopenharmony_ci| event       | [NativeEmbedDataInfo](#nativeembeddatainfo11) | Callback invoked when the lifecycle of the Embed tag changes.|
5254e41f4b71Sopenharmony_ci
5255e41f4b71Sopenharmony_ci**Example**
5256e41f4b71Sopenharmony_ci
5257e41f4b71Sopenharmony_ci```ts
5258e41f4b71Sopenharmony_ci// EntryAbility.ets
5259e41f4b71Sopenharmony_ci
5260e41f4b71Sopenharmony_ciimport { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
5261e41f4b71Sopenharmony_ciimport { hilog } from '@kit.PerformanceAnalysisKit';
5262e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
5263e41f4b71Sopenharmony_ciimport { webview } from '@kit.ArkWeb';
5264e41f4b71Sopenharmony_ci
5265e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
5266e41f4b71Sopenharmony_ci  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
5267e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
5268e41f4b71Sopenharmony_ci    // Added in API version 12: feature to enable the back/forward cache for same-layer rendering.
5269e41f4b71Sopenharmony_ci    let features = new webview.BackForwardCacheSupportedFeatures();
5270e41f4b71Sopenharmony_ci    features.nativeEmbed = true;
5271e41f4b71Sopenharmony_ci    features.mediaTakeOver = true;
5272e41f4b71Sopenharmony_ci    webview.WebviewController.enableBackForwardCache(features);
5273e41f4b71Sopenharmony_ci    webview.WebviewController.initializeWebEngine();
5274e41f4b71Sopenharmony_ci  }
5275e41f4b71Sopenharmony_ci
5276e41f4b71Sopenharmony_ci  onDestroy(): void {
5277e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
5278e41f4b71Sopenharmony_ci  }
5279e41f4b71Sopenharmony_ci
5280e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
5281e41f4b71Sopenharmony_ci    // Main window is created, set main page for this ability
5282e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
5283e41f4b71Sopenharmony_ci
5284e41f4b71Sopenharmony_ci    windowStage.loadContent('pages/Index', (err) => {
5285e41f4b71Sopenharmony_ci      if (err.code) {
5286e41f4b71Sopenharmony_ci        hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
5287e41f4b71Sopenharmony_ci        return;
5288e41f4b71Sopenharmony_ci      }
5289e41f4b71Sopenharmony_ci      hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
5290e41f4b71Sopenharmony_ci    });
5291e41f4b71Sopenharmony_ci  }
5292e41f4b71Sopenharmony_ci
5293e41f4b71Sopenharmony_ci  onWindowStageDestroy(): void {
5294e41f4b71Sopenharmony_ci    // Main window is destroyed, release UI related resources
5295e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
5296e41f4b71Sopenharmony_ci  }
5297e41f4b71Sopenharmony_ci
5298e41f4b71Sopenharmony_ci  onForeground(): void {
5299e41f4b71Sopenharmony_ci    // Ability has brought to foreground
5300e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
5301e41f4b71Sopenharmony_ci  }
5302e41f4b71Sopenharmony_ci
5303e41f4b71Sopenharmony_ci  onBackground(): void {
5304e41f4b71Sopenharmony_ci    // Ability has back to background
5305e41f4b71Sopenharmony_ci    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
5306e41f4b71Sopenharmony_ci  }
5307e41f4b71Sopenharmony_ci}
5308e41f4b71Sopenharmony_ci```
5309e41f4b71Sopenharmony_ci
5310e41f4b71Sopenharmony_ci  ```ts
5311e41f4b71Sopenharmony_ci  // xxx.ets
5312e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5313e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
5314e41f4b71Sopenharmony_ci
5315e41f4b71Sopenharmony_ci  @Entry
5316e41f4b71Sopenharmony_ci  @Component
5317e41f4b71Sopenharmony_ci  struct WebComponent {
5318e41f4b71Sopenharmony_ci    @State embedStatus: string = '';
5319e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5320e41f4b71Sopenharmony_ci
5321e41f4b71Sopenharmony_ci    build() {
5322e41f4b71Sopenharmony_ci      Column() {
5323e41f4b71Sopenharmony_ci        // Default behavior: Click the button to navigate to a new page, close the index page, and destroy the <Embed> tag.
5324e41f4b71Sopenharmony_ci        // Added in API version 12: When BFCache is enabled for the page that supports same-layer rendering, clicking the button navigates to a new page, closes the index page, and puts the <Embed> tag into BFCache.
5325e41f4b71Sopenharmony_ci        Button('Destroy')
5326e41f4b71Sopenharmony_ci        .onClick(() => {
5327e41f4b71Sopenharmony_ci          try {
5328e41f4b71Sopenharmony_ci            this.controller.loadUrl("www.example.com");
5329e41f4b71Sopenharmony_ci          } catch (error) {
5330e41f4b71Sopenharmony_ci            console.error(`ErrorCode: ${(error as BusinessError).code},  Message: ${(error as BusinessError).message}`);
5331e41f4b71Sopenharmony_ci          }
5332e41f4b71Sopenharmony_ci        })
5333e41f4b71Sopenharmony_ci
5334e41f4b71Sopenharmony_ci        // Added in API version 12: When BFCache is enabled for the page that supports same-layer rendering, clicking the button to return to the page causes the <Embed> tag to exit BFCache.
5335e41f4b71Sopenharmony_ci        Button('backward')
5336e41f4b71Sopenharmony_ci        .onClick(() => {
5337e41f4b71Sopenharmony_ci          try {
5338e41f4b71Sopenharmony_ci            this.controller.backward();
5339e41f4b71Sopenharmony_ci          } catch (error) {
5340e41f4b71Sopenharmony_ci            console.error(`ErrorCode: ${(error as BusinessError).code},  Message: ${(error as BusinessError).message}`);
5341e41f4b71Sopenharmony_ci          }
5342e41f4b71Sopenharmony_ci        })
5343e41f4b71Sopenharmony_ci
5344e41f4b71Sopenharmony_ci        // Added in API version 12: When BFCache is enabled for the page that supports same-layer rendering, clicking a button to advance to the next page causes the <Embed> tag to enter BFCache.
5345e41f4b71Sopenharmony_ci        Button('forward')
5346e41f4b71Sopenharmony_ci        .onClick(() => {
5347e41f4b71Sopenharmony_ci          try {
5348e41f4b71Sopenharmony_ci            this.controller.forward();
5349e41f4b71Sopenharmony_ci          } catch (error) {
5350e41f4b71Sopenharmony_ci            console.error(`ErrorCode: ${(error as BusinessError).code},  Message: ${(error as BusinessError).message}`);
5351e41f4b71Sopenharmony_ci          }
5352e41f4b71Sopenharmony_ci        })
5353e41f4b71Sopenharmony_ci
5354e41f4b71Sopenharmony_ci
5355e41f4b71Sopenharmony_ci        // Added in API version 12: The Web kernel does not allow web pages loaded with non-HTTP and non-HTTPS protocols to enter BFCache.
5356e41f4b71Sopenharmony_ci        // Therefore, to test the ENTER_BFCACHE/LEAVE_BFCACHE states, you need to place the index.html on a web server and load it using the HTTP or HTTPS protocol. Example:
5357e41f4b71Sopenharmony_ci        // Web({ src: "http://xxxx/index.html", controller: this.controller })
5358e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
5359e41f4b71Sopenharmony_ci          .enableNativeEmbedMode(true)
5360e41f4b71Sopenharmony_ci          .onNativeEmbedLifecycleChange((event) => {
5361e41f4b71Sopenharmony_ci            // The Create event is triggered when the <Embed> tag is detected on the loaded page.
5362e41f4b71Sopenharmony_ci            if (event.status == NativeEmbedStatus.CREATE) {
5363e41f4b71Sopenharmony_ci              this.embedStatus = 'Create';
5364e41f4b71Sopenharmony_ci            }
5365e41f4b71Sopenharmony_ci            // The Update event is triggered when the <Embed> tag on the page is moved or scaled.
5366e41f4b71Sopenharmony_ci            if (event.status == NativeEmbedStatus.UPDATE) {
5367e41f4b71Sopenharmony_ci              this.embedStatus = 'Update';
5368e41f4b71Sopenharmony_ci            }
5369e41f4b71Sopenharmony_ci            // The Destroy event is triggered when you exit the page.
5370e41f4b71Sopenharmony_ci            if (event.status == NativeEmbedStatus.DESTROY) {
5371e41f4b71Sopenharmony_ci              this.embedStatus = 'Destroy';
5372e41f4b71Sopenharmony_ci            }
5373e41f4b71Sopenharmony_ci            // The Enter BFCache event is triggered when the page with the same-layer tag enters BFCache.
5374e41f4b71Sopenharmony_ci            if (event.status == NativeEmbedStatus.ENTER_BFCACHE) {
5375e41f4b71Sopenharmony_ci              this.embedStatus = 'Enter BFCache';
5376e41f4b71Sopenharmony_ci            }
5377e41f4b71Sopenharmony_ci            // The Leave BFCache event is triggered when the page with the same-layer tag leaves BFCache.
5378e41f4b71Sopenharmony_ci            if (event.status == NativeEmbedStatus.LEAVE_BFCACHE) {
5379e41f4b71Sopenharmony_ci              this.embedStatus = 'Leave BFCache';
5380e41f4b71Sopenharmony_ci            }
5381e41f4b71Sopenharmony_ci            console.log("status = " + this.embedStatus);
5382e41f4b71Sopenharmony_ci            console.log("surfaceId = " + event.surfaceId);
5383e41f4b71Sopenharmony_ci            console.log("embedId = " + event.embedId);
5384e41f4b71Sopenharmony_ci            if (event.info) {
5385e41f4b71Sopenharmony_ci              console.log("id = " + event.info.id);
5386e41f4b71Sopenharmony_ci              console.log("type = " + event.info.type);
5387e41f4b71Sopenharmony_ci              console.log("src = " + event.info.src);
5388e41f4b71Sopenharmony_ci              console.log("width = " + event.info.width);
5389e41f4b71Sopenharmony_ci              console.log("height = " + event.info.height);
5390e41f4b71Sopenharmony_ci              console.log("url = " + event.info.url);
5391e41f4b71Sopenharmony_ci            }
5392e41f4b71Sopenharmony_ci          })
5393e41f4b71Sopenharmony_ci      }
5394e41f4b71Sopenharmony_ci    }
5395e41f4b71Sopenharmony_ci  }
5396e41f4b71Sopenharmony_ci  ```
5397e41f4b71Sopenharmony_ci
5398e41f4b71Sopenharmony_ci  HTML file to be loaded:
5399e41f4b71Sopenharmony_ci  ```
5400e41f4b71Sopenharmony_ci  <!-- index.html -->
5401e41f4b71Sopenharmony_ci  <!Document>
5402e41f4b71Sopenharmony_ci  <html>
5403e41f4b71Sopenharmony_ci  <head>
5404e41f4b71Sopenharmony_ci      <title>Same-layer rendering test HTML</title>
5405e41f4b71Sopenharmony_ci      <meta name="viewport">
5406e41f4b71Sopenharmony_ci  </head>
5407e41f4b71Sopenharmony_ci  <body>
5408e41f4b71Sopenharmony_ci  <div>
5409e41f4b71Sopenharmony_ci      <div id="bodyId">
5410e41f4b71Sopenharmony_ci          <embed id="nativeButton" type = "native/button" width="800" height="800" src="test? params1=1?" style = "background-color:red"/>
5411e41f4b71Sopenharmony_ci      </div>
5412e41f4b71Sopenharmony_ci  </div>
5413e41f4b71Sopenharmony_ci  </body>
5414e41f4b71Sopenharmony_ci  </html>
5415e41f4b71Sopenharmony_ci  ```
5416e41f4b71Sopenharmony_ci
5417e41f4b71Sopenharmony_ci### onNativeEmbedGestureEvent<sup>11+</sup>
5418e41f4b71Sopenharmony_ci
5419e41f4b71Sopenharmony_cionNativeEmbedGestureEvent(callback: NativeEmbedTouchInfo)
5420e41f4b71Sopenharmony_ci
5421e41f4b71Sopenharmony_ciCalled when a finger touches a same-layer rendering tag.
5422e41f4b71Sopenharmony_ci
5423e41f4b71Sopenharmony_ci**Parameters**
5424e41f4b71Sopenharmony_ci
5425e41f4b71Sopenharmony_ci| Name         | Type                                                                        | Description                   |
5426e41f4b71Sopenharmony_ci| -------------- | --------------------------------------------------------------------------- | ---------------------- |
5427e41f4b71Sopenharmony_ci| event       | [NativeEmbedTouchInfo](#nativeembedtouchinfo11) | Callback invoked when a finger touches a same-layer rendering tag.|
5428e41f4b71Sopenharmony_ci
5429e41f4b71Sopenharmony_ci**Example**
5430e41f4b71Sopenharmony_ci
5431e41f4b71Sopenharmony_ci  ```ts
5432e41f4b71Sopenharmony_ci  // xxx.ets
5433e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5434e41f4b71Sopenharmony_ci  import { NodeController, BuilderNode, NodeRenderType, FrameNode, UIContext } from "@kit.ArkUI";
5435e41f4b71Sopenharmony_ci
5436e41f4b71Sopenharmony_ci  declare class Params {
5437e41f4b71Sopenharmony_ci    text: string;
5438e41f4b71Sopenharmony_ci    width: number;
5439e41f4b71Sopenharmony_ci    height: number;
5440e41f4b71Sopenharmony_ci  }
5441e41f4b71Sopenharmony_ci
5442e41f4b71Sopenharmony_ci  declare class nodeControllerParams {
5443e41f4b71Sopenharmony_ci    surfaceId: string;
5444e41f4b71Sopenharmony_ci    renderType: NodeRenderType;
5445e41f4b71Sopenharmony_ci    width: number;
5446e41f4b71Sopenharmony_ci    height: number;
5447e41f4b71Sopenharmony_ci  }
5448e41f4b71Sopenharmony_ci
5449e41f4b71Sopenharmony_ci  class MyNodeController extends NodeController {
5450e41f4b71Sopenharmony_ci    private rootNode: BuilderNode<[Params]> | undefined | null;
5451e41f4b71Sopenharmony_ci    private surfaceId_: string = "";
5452e41f4b71Sopenharmony_ci    private renderType_: NodeRenderType = NodeRenderType.RENDER_TYPE_DISPLAY;
5453e41f4b71Sopenharmony_ci    private width_: number = 0;
5454e41f4b71Sopenharmony_ci    private height_: number = 0;
5455e41f4b71Sopenharmony_ci
5456e41f4b71Sopenharmony_ci    setRenderOption(params: nodeControllerParams) {
5457e41f4b71Sopenharmony_ci      this.surfaceId_ = params.surfaceId;
5458e41f4b71Sopenharmony_ci      this.renderType_ = params.renderType;
5459e41f4b71Sopenharmony_ci      this.width_ = params.width;
5460e41f4b71Sopenharmony_ci      this.height_ = params.height;
5461e41f4b71Sopenharmony_ci    }
5462e41f4b71Sopenharmony_ci
5463e41f4b71Sopenharmony_ci    makeNode(uiContext: UIContext): FrameNode | null {
5464e41f4b71Sopenharmony_ci      this.rootNode = new BuilderNode(uiContext, { surfaceId: this.surfaceId_, type: this.renderType_ });
5465e41f4b71Sopenharmony_ci      this.rootNode.build(wrapBuilder(ButtonBuilder), { text: "myButton", width: this.width_, height: this.height_ });
5466e41f4b71Sopenharmony_ci      return this.rootNode.getFrameNode();
5467e41f4b71Sopenharmony_ci    }
5468e41f4b71Sopenharmony_ci
5469e41f4b71Sopenharmony_ci    postEvent(event: TouchEvent | undefined): boolean {
5470e41f4b71Sopenharmony_ci      return this.rootNode?.postTouchEvent(event) as boolean;
5471e41f4b71Sopenharmony_ci    }
5472e41f4b71Sopenharmony_ci  }
5473e41f4b71Sopenharmony_ci
5474e41f4b71Sopenharmony_ci  @Component
5475e41f4b71Sopenharmony_ci  struct ButtonComponent {
5476e41f4b71Sopenharmony_ci    @Prop params: Params;
5477e41f4b71Sopenharmony_ci    @State bkColor: Color = Color.Red;
5478e41f4b71Sopenharmony_ci
5479e41f4b71Sopenharmony_ci    build() {
5480e41f4b71Sopenharmony_ci      Column() {
5481e41f4b71Sopenharmony_ci        Button(this.params.text)
5482e41f4b71Sopenharmony_ci          .height(50)
5483e41f4b71Sopenharmony_ci          .width(200)
5484e41f4b71Sopenharmony_ci          .border({ width: 2, color: Color.Red })
5485e41f4b71Sopenharmony_ci          .backgroundColor(this.bkColor)
5486e41f4b71Sopenharmony_ci
5487e41f4b71Sopenharmony_ci      }
5488e41f4b71Sopenharmony_ci      .width(this.params.width)
5489e41f4b71Sopenharmony_ci      .height(this.params.height)
5490e41f4b71Sopenharmony_ci    }
5491e41f4b71Sopenharmony_ci  }
5492e41f4b71Sopenharmony_ci
5493e41f4b71Sopenharmony_ci  @Builder
5494e41f4b71Sopenharmony_ci  function ButtonBuilder(params: Params) {
5495e41f4b71Sopenharmony_ci    ButtonComponent({ params: params })
5496e41f4b71Sopenharmony_ci      .backgroundColor(Color.Green)
5497e41f4b71Sopenharmony_ci  }
5498e41f4b71Sopenharmony_ci
5499e41f4b71Sopenharmony_ci  @Entry
5500e41f4b71Sopenharmony_ci  @Component
5501e41f4b71Sopenharmony_ci  struct WebComponent {
5502e41f4b71Sopenharmony_ci    @State eventType: string = '';
5503e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5504e41f4b71Sopenharmony_ci    private nodeController: MyNodeController = new MyNodeController();
5505e41f4b71Sopenharmony_ci
5506e41f4b71Sopenharmony_ci    build() {
5507e41f4b71Sopenharmony_ci      Column() {
5508e41f4b71Sopenharmony_ci        Stack() {
5509e41f4b71Sopenharmony_ci          NodeContainer(this.nodeController)
5510e41f4b71Sopenharmony_ci          Web({ src: $rawfile("index.html"), controller: this.controller })
5511e41f4b71Sopenharmony_ci            .enableNativeEmbedMode(true)
5512e41f4b71Sopenharmony_ci            .onNativeEmbedLifecycleChange((embed) => {
5513e41f4b71Sopenharmony_ci              if (embed.status == NativeEmbedStatus.CREATE) {
5514e41f4b71Sopenharmony_ci                this.nodeController.setRenderOption({
5515e41f4b71Sopenharmony_ci                  surfaceId: embed.surfaceId as string,
5516e41f4b71Sopenharmony_ci                  renderType: NodeRenderType.RENDER_TYPE_TEXTURE,
5517e41f4b71Sopenharmony_ci                  width: px2vp(embed.info?.width),
5518e41f4b71Sopenharmony_ci                  height: px2vp(embed.info?.height)
5519e41f4b71Sopenharmony_ci                });
5520e41f4b71Sopenharmony_ci                this.nodeController.rebuild();
5521e41f4b71Sopenharmony_ci              }
5522e41f4b71Sopenharmony_ci            })
5523e41f4b71Sopenharmony_ci            .onNativeEmbedGestureEvent((event) => {
5524e41f4b71Sopenharmony_ci              if (event && event.touchEvent) {
5525e41f4b71Sopenharmony_ci                if (event.touchEvent.type == TouchType.Down) {
5526e41f4b71Sopenharmony_ci                  this.eventType = 'Down'
5527e41f4b71Sopenharmony_ci                }
5528e41f4b71Sopenharmony_ci                if (event.touchEvent.type == TouchType.Up) {
5529e41f4b71Sopenharmony_ci                  this.eventType = 'Up'
5530e41f4b71Sopenharmony_ci                }
5531e41f4b71Sopenharmony_ci                if (event.touchEvent.type == TouchType.Move) {
5532e41f4b71Sopenharmony_ci                  this.eventType = 'Move'
5533e41f4b71Sopenharmony_ci                }
5534e41f4b71Sopenharmony_ci                if (event.touchEvent.type == TouchType.Cancel) {
5535e41f4b71Sopenharmony_ci                  this.eventType = 'Cancel'
5536e41f4b71Sopenharmony_ci                }
5537e41f4b71Sopenharmony_ci                let ret = this.nodeController.postEvent(event.touchEvent)
5538e41f4b71Sopenharmony_ci                if (event.result) {
5539e41f4b71Sopenharmony_ci                  event.result.setGestureEventResult(ret);
5540e41f4b71Sopenharmony_ci                }
5541e41f4b71Sopenharmony_ci                console.log("embedId = " + event.embedId);
5542e41f4b71Sopenharmony_ci                console.log("touchType = " + this.eventType);
5543e41f4b71Sopenharmony_ci                console.log("x = " + event.touchEvent.touches[0].x);
5544e41f4b71Sopenharmony_ci                console.log("y = " + event.touchEvent.touches[0].y);
5545e41f4b71Sopenharmony_ci                console.log("Component globalPos:(" + event.touchEvent.target.area.globalPosition.x + "," + event.touchEvent.target.area.globalPosition.y + ")");
5546e41f4b71Sopenharmony_ci                console.log("width = " + event.touchEvent.target.area.width);
5547e41f4b71Sopenharmony_ci                console.log("height = " + event.touchEvent.target.area.height);
5548e41f4b71Sopenharmony_ci              }
5549e41f4b71Sopenharmony_ci            })
5550e41f4b71Sopenharmony_ci        }
5551e41f4b71Sopenharmony_ci      }
5552e41f4b71Sopenharmony_ci    }
5553e41f4b71Sopenharmony_ci  }
5554e41f4b71Sopenharmony_ci  ```
5555e41f4b71Sopenharmony_ciHTML file to be loaded:
5556e41f4b71Sopenharmony_ci  ```
5557e41f4b71Sopenharmony_ci  <!-- index.html -->
5558e41f4b71Sopenharmony_ci  <!Document>
5559e41f4b71Sopenharmony_ci<html>
5560e41f4b71Sopenharmony_ci<head>
5561e41f4b71Sopenharmony_ci    <title>Same-layer rendering test HTML</title>
5562e41f4b71Sopenharmony_ci    <meta name="viewport">
5563e41f4b71Sopenharmony_ci</head>
5564e41f4b71Sopenharmony_ci<body>
5565e41f4b71Sopenharmony_ci<div>
5566e41f4b71Sopenharmony_ci    <div id="bodyId">
5567e41f4b71Sopenharmony_ci        <embed id="nativeButton" type = "native/button" width="800" height="800" src="test?params1=1?" style = "background-color:red"/>
5568e41f4b71Sopenharmony_ci    </div>
5569e41f4b71Sopenharmony_ci</div>
5570e41f4b71Sopenharmony_ci</body>
5571e41f4b71Sopenharmony_ci</html>
5572e41f4b71Sopenharmony_ci  ```
5573e41f4b71Sopenharmony_ci
5574e41f4b71Sopenharmony_ci### onIntelligentTrackingPreventionResult<sup>12+</sup>
5575e41f4b71Sopenharmony_ci
5576e41f4b71Sopenharmony_cionIntelligentTrackingPreventionResult(callback: OnIntelligentTrackingPreventionCallback)
5577e41f4b71Sopenharmony_ci
5578e41f4b71Sopenharmony_ciCalled when the intelligent tracking prevention feature is enabled and the tracker cookie is blocked.
5579e41f4b71Sopenharmony_ci
5580e41f4b71Sopenharmony_ci**Parameters**
5581e41f4b71Sopenharmony_ci
5582e41f4b71Sopenharmony_ci| Name      | Type                                                                                        | Description                        |
5583e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------------------------------------------------------- | ---------------------------- |
5584e41f4b71Sopenharmony_ci| callback    | [OnIntelligentTrackingPreventionCallback](#onintelligenttrackingpreventioncallback12) | Callback invoked when the intelligent tracking prevention feature is enabled and the tracker cookie is blocked.|
5585e41f4b71Sopenharmony_ci
5586e41f4b71Sopenharmony_ci**Example**
5587e41f4b71Sopenharmony_ci
5588e41f4b71Sopenharmony_ci  ```ts
5589e41f4b71Sopenharmony_ci  // xxx.ets
5590e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5591e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
5592e41f4b71Sopenharmony_ci
5593e41f4b71Sopenharmony_ci  @Entry
5594e41f4b71Sopenharmony_ci  @Component
5595e41f4b71Sopenharmony_ci  struct WebComponent {
5596e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5597e41f4b71Sopenharmony_ci
5598e41f4b71Sopenharmony_ci    build() {
5599e41f4b71Sopenharmony_ci      Column() {
5600e41f4b71Sopenharmony_ci        // The onIntelligentTrackingPreventionResult callback is triggered only when the intelligent tracking prevention is enabled.
5601e41f4b71Sopenharmony_ci        Button('enableIntelligentTrackingPrevention')
5602e41f4b71Sopenharmony_ci          .onClick(() => {
5603e41f4b71Sopenharmony_ci            try {
5604e41f4b71Sopenharmony_ci              this.controller.enableIntelligentTrackingPrevention(true);
5605e41f4b71Sopenharmony_ci            } catch (error) {
5606e41f4b71Sopenharmony_ci              console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
5607e41f4b71Sopenharmony_ci            }
5608e41f4b71Sopenharmony_ci          })
5609e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
5610e41f4b71Sopenharmony_ci          .onIntelligentTrackingPreventionResult((details) => {
5611e41f4b71Sopenharmony_ci            console.log("onIntelligentTrackingPreventionResult: [websiteHost]= " + details.host +
5612e41f4b71Sopenharmony_ci              ", [trackerHost]=" + details.trackerHost);
5613e41f4b71Sopenharmony_ci          })
5614e41f4b71Sopenharmony_ci      }
5615e41f4b71Sopenharmony_ci    }
5616e41f4b71Sopenharmony_ci  }
5617e41f4b71Sopenharmony_ci  ```
5618e41f4b71Sopenharmony_ci
5619e41f4b71Sopenharmony_ci### onOverrideUrlLoading<sup>12+</sup>
5620e41f4b71Sopenharmony_ci
5621e41f4b71Sopenharmony_cionOverrideUrlLoading(callback: OnOverrideUrlLoadingCallback)
5622e41f4b71Sopenharmony_ci
5623e41f4b71Sopenharmony_ciCalled to enable the host application to obtain control when the URL is about to be loaded to this **Web** component. If the callback returns **true**, the **\<Web>** component stops loading the URL. If the callback returns **false**, the **Web** component continues to load the URL.
5624e41f4b71Sopenharmony_ci
5625e41f4b71Sopenharmony_ciPOST requests do not trigger this callback.
5626e41f4b71Sopenharmony_ci
5627e41f4b71Sopenharmony_ciThis callback is triggered when the **iframe** loads the redirection of a non-HTTP(s) protocol, but is not triggered when the **iframe** loads the HTTP(s) protocol or **about:blank** and when the redirection initiated by **loadUrl(String)** is called.
5628e41f4b71Sopenharmony_ci
5629e41f4b71Sopenharmony_ciDo not use the same URL to call the **loadUrl(String)** API and then return **true**. Doing so would unnecessarily cancel the current loading and start a new load with the same URL. The correct way to continue loading the given URL is to simply return **false**, rather than calling **loadUrl(String)**.
5630e41f4b71Sopenharmony_ci
5631e41f4b71Sopenharmony_ci**Parameters**
5632e41f4b71Sopenharmony_ci
5633e41f4b71Sopenharmony_ci| Name         | Type                                                                        | Description                   |
5634e41f4b71Sopenharmony_ci| -------------- | --------------------------------------------------------------------------- | ---------------------- |
5635e41f4b71Sopenharmony_ci| callback       | [OnOverrideUrlLoadingCallback](#onoverrideurlloadingcallback12) | Callback for **onOverrideUrlLoading**.|
5636e41f4b71Sopenharmony_ci
5637e41f4b71Sopenharmony_ci**Example**
5638e41f4b71Sopenharmony_ci
5639e41f4b71Sopenharmony_ci  ```ts
5640e41f4b71Sopenharmony_ci  // xxx.ets
5641e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5642e41f4b71Sopenharmony_ci
5643e41f4b71Sopenharmony_ci  @Entry
5644e41f4b71Sopenharmony_ci  @Component
5645e41f4b71Sopenharmony_ci  struct WebComponent {
5646e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5647e41f4b71Sopenharmony_ci
5648e41f4b71Sopenharmony_ci    build() {
5649e41f4b71Sopenharmony_ci      Column() {
5650e41f4b71Sopenharmony_ci        Web({ src: $rawfile("index.html"), controller: this.controller })
5651e41f4b71Sopenharmony_ci          .onOverrideUrlLoading((webResourceRequest: WebResourceRequest) => {
5652e41f4b71Sopenharmony_ci            if (webResourceRequest && webResourceRequest.getRequestUrl() == "about:blank") {
5653e41f4b71Sopenharmony_ci              return true;
5654e41f4b71Sopenharmony_ci            }
5655e41f4b71Sopenharmony_ci            return false;
5656e41f4b71Sopenharmony_ci          })
5657e41f4b71Sopenharmony_ci      }
5658e41f4b71Sopenharmony_ci    }
5659e41f4b71Sopenharmony_ci  }
5660e41f4b71Sopenharmony_ci  ```
5661e41f4b71Sopenharmony_ci
5662e41f4b71Sopenharmony_ci  HTML file to be loaded:
5663e41f4b71Sopenharmony_ci  ```html
5664e41f4b71Sopenharmony_ci  <!--index.html-->
5665e41f4b71Sopenharmony_ci  <!DOCTYPE html>
5666e41f4b71Sopenharmony_ci  <html>
5667e41f4b71Sopenharmony_ci  <head>
5668e41f4b71Sopenharmony_ci    <title>Test Web Page</title>
5669e41f4b71Sopenharmony_ci  </head>
5670e41f4b71Sopenharmony_ci  <body>
5671e41f4b71Sopenharmony_ci    <h1>onOverrideUrlLoading Demo</h1>
5672e41f4b71Sopenharmony_ci    <a href="about:blank">Click here</a> to visit about:blank.
5673e41f4b71Sopenharmony_ci  </body>
5674e41f4b71Sopenharmony_ci  </html>
5675e41f4b71Sopenharmony_ci  ```
5676e41f4b71Sopenharmony_ci
5677e41f4b71Sopenharmony_ci### onViewportFitChanged<sup>12+</sup>
5678e41f4b71Sopenharmony_ci
5679e41f4b71Sopenharmony_cionViewportFitChanged(callback: OnViewportFitChangedCallback)
5680e41f4b71Sopenharmony_ci
5681e41f4b71Sopenharmony_ciCalled when the **viewport-fit** configuration in the web page's **\<meta>** tag changes. The application can adapt its layout to the viewport within this callback.
5682e41f4b71Sopenharmony_ci
5683e41f4b71Sopenharmony_ci**Parameters**
5684e41f4b71Sopenharmony_ci
5685e41f4b71Sopenharmony_ci| Name  | Type                                                        | Description                                  |
5686e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | -------------------------------------- |
5687e41f4b71Sopenharmony_ci| callback | [OnViewportFitChangedCallback](#onviewportfitchangedcallback12) | Callback invoked when the **viewport-fit** configuration in the web page's **\<meta>** tag changes.|
5688e41f4b71Sopenharmony_ci
5689e41f4b71Sopenharmony_ci**Example**
5690e41f4b71Sopenharmony_ci
5691e41f4b71Sopenharmony_ci  ```ts
5692e41f4b71Sopenharmony_ci  // xxx.ets
5693e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5694e41f4b71Sopenharmony_ci
5695e41f4b71Sopenharmony_ci  @Entry
5696e41f4b71Sopenharmony_ci  @Component
5697e41f4b71Sopenharmony_ci  struct WebComponent {
5698e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5699e41f4b71Sopenharmony_ci
5700e41f4b71Sopenharmony_ci    build() {
5701e41f4b71Sopenharmony_ci      Column() {
5702e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
5703e41f4b71Sopenharmony_ci          .onViewportFitChanged((data) => {
5704e41f4b71Sopenharmony_ci            let jsonData = JSON.stringify(data);
5705e41f4b71Sopenharmony_ci            let viewportFit: ViewportFit = JSON.parse(jsonData).viewportFit;
5706e41f4b71Sopenharmony_ci            if (viewportFit === ViewportFit.COVER) {
5707e41f4b71Sopenharmony_ci              // The index.html web page supports immersive layout. You can call expandSafeArea to adjust the Web component layout viewport to cover the safe area (status bar or navigation bar).
5708e41f4b71Sopenharmony_ci            } else if (viewportFit === ViewportFit.CONTAINS) {
5709e41f4b71Sopenharmony_ci              // The index.html web page does not support immersive layout. You can call expandSafeArea to adjust the Web component layout viewport as a safe area.
5710e41f4b71Sopenharmony_ci            } else {
5711e41f4b71Sopenharmony_ci              // Default value. No processing is required.
5712e41f4b71Sopenharmony_ci            }
5713e41f4b71Sopenharmony_ci          })
5714e41f4b71Sopenharmony_ci      }
5715e41f4b71Sopenharmony_ci    }
5716e41f4b71Sopenharmony_ci  }
5717e41f4b71Sopenharmony_ci  ```
5718e41f4b71Sopenharmony_ci
5719e41f4b71Sopenharmony_ci  HTML file to be loaded:
5720e41f4b71Sopenharmony_ci  ```html
5721e41f4b71Sopenharmony_ci  <!-- index.html -->
5722e41f4b71Sopenharmony_ci  <!DOCTYPE html>
5723e41f4b71Sopenharmony_ci  <html>
5724e41f4b71Sopenharmony_ci    <head>
5725e41f4b71Sopenharmony_ci      <meta name="viewport" content="width=device-width,viewport-fit=cover">
5726e41f4b71Sopenharmony_ci    </head>
5727e41f4b71Sopenharmony_ci    <body>
5728e41f4b71Sopenharmony_ci      <div style="position: absolute; bottom: 0; margin-bottom: env(safe-area-inset-bottom)"></div>
5729e41f4b71Sopenharmony_ci    </body>
5730e41f4b71Sopenharmony_ci  </html>
5731e41f4b71Sopenharmony_ci  ```
5732e41f4b71Sopenharmony_ci
5733e41f4b71Sopenharmony_ci### onInterceptKeyboardAttach<sup>12+</sup>
5734e41f4b71Sopenharmony_ci
5735e41f4b71Sopenharmony_cionInterceptKeyboardAttach(callback: WebKeyboardCallback)
5736e41f4b71Sopenharmony_ci
5737e41f4b71Sopenharmony_ciCalled before any editable element (such as the **\<input>** tag) on the web page invokes the soft keyboard. The application can use this API to intercept the display of the system's soft keyboard and configure a custom soft keyboard. (With this API, the application can determine whether to use the system's default soft keyboard, a system soft keyboard with a custom Enter key, or a completely application-defined soft keyboard).
5738e41f4b71Sopenharmony_ci
5739e41f4b71Sopenharmony_ci**Parameters**
5740e41f4b71Sopenharmony_ci
5741e41f4b71Sopenharmony_ci| Name  | Type                                                        | Description                                  |
5742e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | -------------------------------------- |
5743e41f4b71Sopenharmony_ci| callback | [WebKeyboardCallback](#webkeyboardcallback12) | Callback invoked for intercepting the soft keyboard invoking in the web page.|
5744e41f4b71Sopenharmony_ci
5745e41f4b71Sopenharmony_ci**Example**
5746e41f4b71Sopenharmony_ci
5747e41f4b71Sopenharmony_ci  ```ts
5748e41f4b71Sopenharmony_ci  // xxx.ets
5749e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5750e41f4b71Sopenharmony_ci  import { inputMethodEngine } from '@kit.IMEKit';
5751e41f4b71Sopenharmony_ci
5752e41f4b71Sopenharmony_ci  @Entry
5753e41f4b71Sopenharmony_ci  @Component
5754e41f4b71Sopenharmony_ci  struct WebComponent {
5755e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5756e41f4b71Sopenharmony_ci    webKeyboardController: WebKeyboardController = new WebKeyboardController()
5757e41f4b71Sopenharmony_ci    inputAttributeMap: Map<string, number> = new Map([
5758e41f4b71Sopenharmony_ci        ['UNSPECIFIED', inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED],
5759e41f4b71Sopenharmony_ci        ['GO', inputMethodEngine.ENTER_KEY_TYPE_GO],
5760e41f4b71Sopenharmony_ci        ['SEARCH', inputMethodEngine.ENTER_KEY_TYPE_SEARCH],
5761e41f4b71Sopenharmony_ci        ['SEND', inputMethodEngine.ENTER_KEY_TYPE_SEND],
5762e41f4b71Sopenharmony_ci        ['NEXT', inputMethodEngine.ENTER_KEY_TYPE_NEXT],
5763e41f4b71Sopenharmony_ci        ['DONE', inputMethodEngine.ENTER_KEY_TYPE_DONE],
5764e41f4b71Sopenharmony_ci        ['PREVIOUS', inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS]
5765e41f4b71Sopenharmony_ci      ])
5766e41f4b71Sopenharmony_ci
5767e41f4b71Sopenharmony_ci      /**
5768e41f4b71Sopenharmony_ci       * Builder for a custom keyboard component
5769e41f4b71Sopenharmony_ci       */
5770e41f4b71Sopenharmony_ci      @Builder
5771e41f4b71Sopenharmony_ci      customKeyboardBuilder() {
5772e41f4b71Sopenharmony_ci		  // Implement a custom keyboard component and connect to the WebKeyboardController to implement operations such as input, deletion, and close.
5773e41f4b71Sopenharmony_ci        Row() {
5774e41f4b71Sopenharmony_ci          Text("Finish")
5775e41f4b71Sopenharmony_ci            .fontSize(20)
5776e41f4b71Sopenharmony_ci            .fontColor(Color.Blue)
5777e41f4b71Sopenharmony_ci            .onClick(() => {
5778e41f4b71Sopenharmony_ci              this.webKeyboardController.close();
5779e41f4b71Sopenharmony_ci            })
5780e41f4b71Sopenharmony_ci          // Insert characters.
5781e41f4b71Sopenharmony_ci          Button("insertText").onClick(() => {
5782e41f4b71Sopenharmony_ci            this.webKeyboardController.insertText('insert ');
5783e41f4b71Sopenharmony_ci          }).margin({
5784e41f4b71Sopenharmony_ci            bottom: 200,
5785e41f4b71Sopenharmony_ci          })
5786e41f4b71Sopenharmony_ci          // Delete characters from the end to the beginning for the length specified by the length parameter.
5787e41f4b71Sopenharmony_ci          Button("deleteForward").onClick(() => {
5788e41f4b71Sopenharmony_ci            this.webKeyboardController.deleteForward(1);
5789e41f4b71Sopenharmony_ci          }).margin({
5790e41f4b71Sopenharmony_ci            bottom: 200,
5791e41f4b71Sopenharmony_ci          })
5792e41f4b71Sopenharmony_ci          // Delete characters from the beginning to the end for the length specified by the length parameter.
5793e41f4b71Sopenharmony_ci          Button("deleteBackward").onClick(() => {
5794e41f4b71Sopenharmony_ci            this.webKeyboardController.deleteBackward(1);
5795e41f4b71Sopenharmony_ci          }).margin({
5796e41f4b71Sopenharmony_ci            left: -220,
5797e41f4b71Sopenharmony_ci          })
5798e41f4b71Sopenharmony_ci          // Insert a function key.
5799e41f4b71Sopenharmony_ci          Button("sendFunctionKey").onClick(() => {
5800e41f4b71Sopenharmony_ci            this.webKeyboardController.sendFunctionKey(6);
5801e41f4b71Sopenharmony_ci          })
5802e41f4b71Sopenharmony_ci        }
5803e41f4b71Sopenharmony_ci      }
5804e41f4b71Sopenharmony_ci
5805e41f4b71Sopenharmony_ci    build() {
5806e41f4b71Sopenharmony_ci      Column() {
5807e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
5808e41f4b71Sopenharmony_ci        .onInterceptKeyboardAttach((KeyboardCallbackInfo) => {
5809e41f4b71Sopenharmony_ci          // Initialize option. By default, the default keyboard is used.
5810e41f4b71Sopenharmony_ci          let option: WebKeyboardOptions = {
5811e41f4b71Sopenharmony_ci            useSystemKeyboard: true,
5812e41f4b71Sopenharmony_ci          };
5813e41f4b71Sopenharmony_ci          if (!KeyboardCallbackInfo) {
5814e41f4b71Sopenharmony_ci            return option;
5815e41f4b71Sopenharmony_ci          }
5816e41f4b71Sopenharmony_ci
5817e41f4b71Sopenharmony_ci          // Save the WebKeyboardController. When using a custom keyboard, this handler is required to control behaviors such as input, deletion, and closing of the soft keyboard.
5818e41f4b71Sopenharmony_ci          this.webKeyboardController = KeyboardCallbackInfo.controller
5819e41f4b71Sopenharmony_ci          let attributes: Record<string, string> = KeyboardCallbackInfo.attributes
5820e41f4b71Sopenharmony_ci          // Traverse attributes.
5821e41f4b71Sopenharmony_ci          let attributeKeys = Object.keys(attributes)
5822e41f4b71Sopenharmony_ci          for (let i = 0; i < attributeKeys.length; i++) {
5823e41f4b71Sopenharmony_ci            console.log('WebCustomKeyboard key = ' + attributeKeys[i] + ', value = ' + attributes[attributeKeys[i]])
5824e41f4b71Sopenharmony_ci          }
5825e41f4b71Sopenharmony_ci
5826e41f4b71Sopenharmony_ci          if (attributes) {
5827e41f4b71Sopenharmony_ci            if (attributes['data-keyboard'] == 'customKeyboard') {
5828e41f4b71Sopenharmony_ci              // Determine the soft keyboard to use based on the attributes of editable HTML elements. For example, if the attribute includes data-keyboard and its value is customKeyboard, use a custom keyboard.
5829e41f4b71Sopenharmony_ci              console.log('WebCustomKeyboard use custom keyboard')
5830e41f4b71Sopenharmony_ci              option.useSystemKeyboard = false;
5831e41f4b71Sopenharmony_ci              // Sets the custom keyboard builder.
5832e41f4b71Sopenharmony_ci              option.customKeyboard = () => {
5833e41f4b71Sopenharmony_ci                this.customKeyboardBuilder()
5834e41f4b71Sopenharmony_ci              }
5835e41f4b71Sopenharmony_ci              return option;
5836e41f4b71Sopenharmony_ci            }
5837e41f4b71Sopenharmony_ci
5838e41f4b71Sopenharmony_ci            if (attributes['keyboard-return'] != undefined) {
5839e41f4b71Sopenharmony_ci              // Determine the soft keyboard to use based on the attributes of editable HTML elements. For example, if the attribute includes keyboard-return, use the system keyboard and specify the type of the system soft keyboard's Enter key.
5840e41f4b71Sopenharmony_ci              option.useSystemKeyboard = true;
5841e41f4b71Sopenharmony_ci              let enterKeyType: number | undefined = this.inputAttributeMap.get(attributes['keyboard-return'])
5842e41f4b71Sopenharmony_ci              if (enterKeyType != undefined) {
5843e41f4b71Sopenharmony_ci                option.enterKeyType = enterKeyType
5844e41f4b71Sopenharmony_ci              }
5845e41f4b71Sopenharmony_ci              return option;
5846e41f4b71Sopenharmony_ci            }
5847e41f4b71Sopenharmony_ci          }
5848e41f4b71Sopenharmony_ci
5849e41f4b71Sopenharmony_ci          return option;
5850e41f4b71Sopenharmony_ci        })
5851e41f4b71Sopenharmony_ci      }
5852e41f4b71Sopenharmony_ci    }
5853e41f4b71Sopenharmony_ci  }
5854e41f4b71Sopenharmony_ci  ```
5855e41f4b71Sopenharmony_ci
5856e41f4b71Sopenharmony_ci  HTML file to be loaded:
5857e41f4b71Sopenharmony_ci  ```html
5858e41f4b71Sopenharmony_ci  <!-- index.html -->
5859e41f4b71Sopenharmony_ci    <!DOCTYPE html>
5860e41f4b71Sopenharmony_ci    <html>
5861e41f4b71Sopenharmony_ci
5862e41f4b71Sopenharmony_ci    <head>
5863e41f4b71Sopenharmony_ci        <meta charset="utf-8">
5864e41f4b71Sopenharmony_ci        <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0">
5865e41f4b71Sopenharmony_ci    </head>
5866e41f4b71Sopenharmony_ci
5867e41f4b71Sopenharmony_ci    <body>
5868e41f4b71Sopenharmony_ci
5869e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. Original default behavior: </p>
5870e41f4b71Sopenharmony_ci    <input type="text" style="width: 300px; height: 20px"><br>
5871e41f4b71Sopenharmony_ci    <hr style="height:2px;border-width:0;color:gray;background-color:gray">
5872e41f4b71Sopenharmony_ci
5873e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. System keyboard with enterKeyType as UNSPECIFIED: </p>
5874e41f4b71Sopenharmony_ci    <input type="text" keyboard-return="UNSPECIFIED" style="width: 300px; height: 20px"><br>
5875e41f4b71Sopenharmony_ci    <hr style="height:2px;border-width:0;color:gray;background-color:gray">
5876e41f4b71Sopenharmony_ci
5877e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. System keyboard with enterKeyType as GO: </p>
5878e41f4b71Sopenharmony_ci    <input type="text" keyboard-return="GO" style="width: 300px; height: 20px"><br>
5879e41f4b71Sopenharmony_ci    <hr style="height:2px;border-width:0;color:gray;background-color:gray">
5880e41f4b71Sopenharmony_ci
5881e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. System keyboard with enterKeyType as SEARCH: </p>
5882e41f4b71Sopenharmony_ci    <input type="text" keyboard-return="SEARCH" style="width: 300px; height: 20px"><br>
5883e41f4b71Sopenharmony_ci    <hr style="height:2px;border-width:0;color:gray;background-color:gray">
5884e41f4b71Sopenharmony_ci
5885e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. System keyboard with enterKeyType as SEND: </p>
5886e41f4b71Sopenharmony_ci    <input type="text" keyboard-return="SEND" style="width: 300px; height: 20px"><br>
5887e41f4b71Sopenharmony_ci    <hr style="height:2px;border-width:0;color:gray;background-color:gray">
5888e41f4b71Sopenharmony_ci
5889e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. System keyboard with enterKeyType as NEXT: </p>
5890e41f4b71Sopenharmony_ci    <input type="text" keyboard-return="NEXT" style="width: 300px; height: 20px"><br>
5891e41f4b71Sopenharmony_ci    <hr style="height:2px;border-width:0;color:gray;background-color:gray">
5892e41f4b71Sopenharmony_ci
5893e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. System keyboard with enterKeyType as DONE: </p>
5894e41f4b71Sopenharmony_ci    <input type="text" keyboard-return="DONE" style="width: 300px; height: 20px"><br>
5895e41f4b71Sopenharmony_ci    <hr style="height:2px;border-width:0;color:gray;background-color:gray">
5896e41f4b71Sopenharmony_ci
5897e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. System keyboard with enterKeyType as PREVIOUS: </p>
5898e41f4b71Sopenharmony_ci    <input type="text" keyboard-return="PREVIOUS" style="width: 300px; height: 20px"><br>
5899e41f4b71Sopenharmony_ci    <hr style="height:2px;border-width:0;color:gray;background-color:gray">
5900e41f4b71Sopenharmony_ci
5901e41f4b71Sopenharmony_ci    <p style="font-size:12px">input tag. Custom keyboard: </p>
5902e41f4b71Sopenharmony_ci    <input type="text" data-keyboard="customKeyboard" style="width: 300px; height: 20px"><br>
5903e41f4b71Sopenharmony_ci
5904e41f4b71Sopenharmony_ci    </body>
5905e41f4b71Sopenharmony_ci
5906e41f4b71Sopenharmony_ci    </html>
5907e41f4b71Sopenharmony_ci  ```
5908e41f4b71Sopenharmony_ci
5909e41f4b71Sopenharmony_ci### onNativeEmbedVisibilityChange<sup>12+</sup>
5910e41f4b71Sopenharmony_ci
5911e41f4b71Sopenharmony_cionNativeEmbedVisibilityChange(callback: OnNativeEmbedVisibilityChangeCallback)
5912e41f4b71Sopenharmony_ci
5913e41f4b71Sopenharmony_ciCalled when the visibility of a same-layer rendering tag (such as an **Embed** tag or an **Object** tag) on a web page changes in the viewport. By default, the same-layer rendering tag is invisible. If the rendering tag is visible when you access the page for the first time, the callback is triggered; otherwise, it is not triggered. That is, if the same-layer rendering tag changes from a non-zero value to **0 x 0**, the callback is triggered. If the rendering tag size changes from **0 x 0** to a non-zero value, the callback is not triggered. If all the same-layer rendering tags are invisible, they are reported as invisible. If all the same-layer rendering tags or part of them are visible, they are reported as invisible.
5914e41f4b71Sopenharmony_ci
5915e41f4b71Sopenharmony_ci**Parameters**
5916e41f4b71Sopenharmony_ci
5917e41f4b71Sopenharmony_ci| Name         | Type                                                                        | Description                   |
5918e41f4b71Sopenharmony_ci| -------------- | --------------------------------------------------------------------------- | ---------------------- |
5919e41f4b71Sopenharmony_ci| callback       | [OnNativeEmbedVisibilityChangeCallback](#onnativeembedvisibilitychangecallback12) | Called when the visibility of a same-layer rendering tag changes.|
5920e41f4b71Sopenharmony_ci
5921e41f4b71Sopenharmony_ci**Example**
5922e41f4b71Sopenharmony_ci  ```ts
5923e41f4b71Sopenharmony_ci  // xxx.ets
5924e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
5925e41f4b71Sopenharmony_ci
5926e41f4b71Sopenharmony_ci  @Entry
5927e41f4b71Sopenharmony_ci  @Component
5928e41f4b71Sopenharmony_ci  struct WebComponent {
5929e41f4b71Sopenharmony_ci    @State embedVisibility: string = '';
5930e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
5931e41f4b71Sopenharmony_ci
5932e41f4b71Sopenharmony_ci    build() {
5933e41f4b71Sopenharmony_ci      Column() {
5934e41f4b71Sopenharmony_ci        Stack() {
5935e41f4b71Sopenharmony_ci          Web({ src: $rawfile("index.html"), controller: this.controller })
5936e41f4b71Sopenharmony_ci            .enableNativeEmbedMode(true)
5937e41f4b71Sopenharmony_ci            .onNativeEmbedVisibilityChange((embed) => {
5938e41f4b71Sopenharmony_ci              if (embed.visibility) {
5939e41f4b71Sopenharmony_ci                this.embedVisibility = 'Visible';
5940e41f4b71Sopenharmony_ci              } else {
5941e41f4b71Sopenharmony_ci                this.embedVisibility = 'Hidden';
5942e41f4b71Sopenharmony_ci              }
5943e41f4b71Sopenharmony_ci              console.log("embedId = " + embed.embedId);
5944e41f4b71Sopenharmony_ci              console.log("visibility = " + embed.visibility);
5945e41f4b71Sopenharmony_ci            })
5946e41f4b71Sopenharmony_ci        }
5947e41f4b71Sopenharmony_ci      }
5948e41f4b71Sopenharmony_ci    }
5949e41f4b71Sopenharmony_ci  }
5950e41f4b71Sopenharmony_ci  ```
5951e41f4b71Sopenharmony_ci
5952e41f4b71Sopenharmony_ci  HTML file to be loaded:
5953e41f4b71Sopenharmony_ci  ```html
5954e41f4b71Sopenharmony_ci  <!-- index.html -->
5955e41f4b71Sopenharmony_ci  <!DOCTYPE html>
5956e41f4b71Sopenharmony_ci  <html>
5957e41f4b71Sopenharmony_ci  <head>
5958e41f4b71Sopenharmony_ci      <title>Same-layer rendering test HTML</title>
5959e41f4b71Sopenharmony_ci      <meta name="viewport">
5960e41f4b71Sopenharmony_ci  </head>
5961e41f4b71Sopenharmony_ci  <body>
5962e41f4b71Sopenharmony_ci  <div>
5963e41f4b71Sopenharmony_ci      <div id="bodyId">
5964e41f4b71Sopenharmony_ci          <embed id="nativeVideo" type = "native/video" width="800" height="800" src="test? params1=1?" style = "background-color:red"/>
5965e41f4b71Sopenharmony_ci      </div>
5966e41f4b71Sopenharmony_ci  </div>
5967e41f4b71Sopenharmony_ci  </body>
5968e41f4b71Sopenharmony_ci  </html>
5969e41f4b71Sopenharmony_ci  ```
5970e41f4b71Sopenharmony_ci
5971e41f4b71Sopenharmony_ci## WebKeyboardCallback<sup>12+</sup>
5972e41f4b71Sopenharmony_ci
5973e41f4b71Sopenharmony_citype WebKeyboardCallback = (keyboardCallbackInfo: WebKeyboardCallbackInfo) => WebKeyboardOptions
5974e41f4b71Sopenharmony_ci
5975e41f4b71Sopenharmony_ciCalled to intercept the soft keyboard from editable elements on a web page. This event is typically called when the **\<input>** tag on the web page is clicked.
5976e41f4b71Sopenharmony_ci
5977e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Web.Webview.Core
5978e41f4b71Sopenharmony_ci
5979e41f4b71Sopenharmony_ci**Parameters**
5980e41f4b71Sopenharmony_ci
5981e41f4b71Sopenharmony_ci| Name          | Type  | Mandatory  | Description              |
5982e41f4b71Sopenharmony_ci| ------------- | ------ | ---- | ------------------ |
5983e41f4b71Sopenharmony_ci| keyboardCallbackInfo    | [WebKeyboardCallbackInfo](#webkeyboardcallbackinfo12) | Yes   | Input parameter of the callback for intercepting the soft keyboard from editable elements on a web page, including [WebKeyboardController](#webkeyboardcontroller12) and editable element attributes. |
5984e41f4b71Sopenharmony_ci
5985e41f4b71Sopenharmony_ci
5986e41f4b71Sopenharmony_ci**Return value**
5987e41f4b71Sopenharmony_ci
5988e41f4b71Sopenharmony_ci| Type              | Description                                                        |
5989e41f4b71Sopenharmony_ci| ------------------ | ------------------------------------------------------------ |
5990e41f4b71Sopenharmony_ci| [WebKeyboardOptions](#webkeyboardoptions12) | [WebKeyboardOptions](#webkeyboardoptions12) instance, which is used to determine which type of soft keyboard to start by the ArkWeb rendering engine.|
5991e41f4b71Sopenharmony_ci
5992e41f4b71Sopenharmony_ci## WebKeyboardCallbackInfo<sup>12+</sup>
5993e41f4b71Sopenharmony_ci
5994e41f4b71Sopenharmony_ciRepresents the input parameter of the callback for intercepting the soft keyboard from editable elements on a web page, including [WebKeyboardController](#webkeyboardcontroller12) and editable element attributes.
5995e41f4b71Sopenharmony_ci
5996e41f4b71Sopenharmony_ci| Name            | Type     | Readable  | Writable  | Mandatory  | Description                                      |
5997e41f4b71Sopenharmony_ci| -------------- | ------- | ---- | ---- | ---- | ---------------------------------------- |
5998e41f4b71Sopenharmony_ci| controller | [WebKeyboardController](#webkeyboardcontroller12)  | Yes   | No   | Yes   | Controller used to control the input, deletion, and closure of the custom keyboard.|
5999e41f4b71Sopenharmony_ci| attributes | Record<string, string> | Yes   | No   | Yes   | Attributes of the web page element that triggered the soft keyboard to pop up.
6000e41f4b71Sopenharmony_ci
6001e41f4b71Sopenharmony_ci## WebKeyboardOptions<sup>12+</sup>
6002e41f4b71Sopenharmony_ci
6003e41f4b71Sopenharmony_ciRepresents the return value of the callback that intercepts the soft keyboard from editable elements on the web page. You can specify the type of the keyboard to be used, and it is returned to the Web kernel to display a keyboard of the corresponding type.
6004e41f4b71Sopenharmony_ci
6005e41f4b71Sopenharmony_ci| Name            | Type     | Readable  | Writable  | Mandatory  | Description                                      |
6006e41f4b71Sopenharmony_ci| -------------- | ------- | ---- | ---- | ---- | ---------------------------------------- |
6007e41f4b71Sopenharmony_ci| useSystemKeyboard | boolean  | Yes   | Yes   | Yes   | Whether to use the system's default soft keyboard.|
6008e41f4b71Sopenharmony_ci| enterKeyType | number | Yes   | Yes   | No   | Type of the Enter key of the system soft keyboard. For details about the value range, see [EnterKeyType](../apis-ime-kit/js-apis-inputmethod.md#enterkeytype10). This parameter has effect only when **useSystemKeyboard** is set to **true** and **enterKeyType** is set to a valid value.|
6009e41f4b71Sopenharmony_ci| customKeyboard | [CustomBuilder](../apis-arkui/arkui-ts/ts-types.md#custombuilder8) | Yes   | Yes   | No   | Builder of a custom keyboard. This parameter is required when **useSystemKeyboard** is set to **false**. After it is set, the Web component starts the custom keyboard as configured.
6010e41f4b71Sopenharmony_ci
6011e41f4b71Sopenharmony_ci## WebKeyboardController<sup>12+</sup>
6012e41f4b71Sopenharmony_ci
6013e41f4b71Sopenharmony_ciImplements a controller to control the input, deletion, and closure of the custom keyboard. For details about the sample code, see [onInterceptKeyboardAttach](#oninterceptkeyboardattach12).
6014e41f4b71Sopenharmony_ci
6015e41f4b71Sopenharmony_ci### insertText<sup>12+</sup>
6016e41f4b71Sopenharmony_ci
6017e41f4b71Sopenharmony_ciinsertText(text: string): void
6018e41f4b71Sopenharmony_ci
6019e41f4b71Sopenharmony_ciInserts a character.
6020e41f4b71Sopenharmony_ci
6021e41f4b71Sopenharmony_ci**Parameters**
6022e41f4b71Sopenharmony_ci
6023e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Default Value| Description             |
6024e41f4b71Sopenharmony_ci| ------ | -------- | ---- | ------ | --------------------- |
6025e41f4b71Sopenharmony_ci| text   | string   | Yes  | -      | Character to insert into the **Web** component text box.|
6026e41f4b71Sopenharmony_ci
6027e41f4b71Sopenharmony_ci### deleteForward<sup>12+</sup>
6028e41f4b71Sopenharmony_ci
6029e41f4b71Sopenharmony_cideleteForward(length: number): void
6030e41f4b71Sopenharmony_ci
6031e41f4b71Sopenharmony_ciDeletes characters from the end to the beginning for the length specified by the **length** parameter.
6032e41f4b71Sopenharmony_ci
6033e41f4b71Sopenharmony_ci**Parameters**
6034e41f4b71Sopenharmony_ci
6035e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Default Value| Description                |
6036e41f4b71Sopenharmony_ci| ------ | -------- | ---- | ------ | ------------------------ |
6037e41f4b71Sopenharmony_ci| length | number   | Yes  | -      | Length of characters to be deleted from the end to the beginning.|
6038e41f4b71Sopenharmony_ci
6039e41f4b71Sopenharmony_ci### deleteBackward12+</sup>
6040e41f4b71Sopenharmony_ci
6041e41f4b71Sopenharmony_cideleteBackward(length: number): void
6042e41f4b71Sopenharmony_ci
6043e41f4b71Sopenharmony_ciDeletes characters from the beginning to the end for the length specified by the **length** parameter.
6044e41f4b71Sopenharmony_ci
6045e41f4b71Sopenharmony_ci**Parameters**
6046e41f4b71Sopenharmony_ci
6047e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Default Value| Description                |
6048e41f4b71Sopenharmony_ci| ------ | -------- | ---- | ------ | ------------------------ |
6049e41f4b71Sopenharmony_ci| length | number   | Yes  | -      | Length of characters to be deleted from the beginning to the end.|
6050e41f4b71Sopenharmony_ci
6051e41f4b71Sopenharmony_ci### sendFunctionKey<sup>12+</sup>
6052e41f4b71Sopenharmony_ci
6053e41f4b71Sopenharmony_cisendFunctionKey(key: number): void
6054e41f4b71Sopenharmony_ci
6055e41f4b71Sopenharmony_ciInserts a function key. Currently, only the Enter key type is supported. For details about the value, see [EnterKeyType](../apis-ime-kit/js-apis-inputmethod.md#enterkeytype10).
6056e41f4b71Sopenharmony_ci
6057e41f4b71Sopenharmony_ci**Parameters**
6058e41f4b71Sopenharmony_ci
6059e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Default Value| Description                                  |
6060e41f4b71Sopenharmony_ci| ------ | -------- | ---- | ------ | ------------------------------------------ |
6061e41f4b71Sopenharmony_ci| key    | number   | Yes  | -      | Function key to insert into the **Web** component text box. Currently, only the Enter key is supported.|
6062e41f4b71Sopenharmony_ci
6063e41f4b71Sopenharmony_ci### close<sup>12+</sup>
6064e41f4b71Sopenharmony_ci
6065e41f4b71Sopenharmony_ciclose(): void
6066e41f4b71Sopenharmony_ci
6067e41f4b71Sopenharmony_ciCloses this custom keyboard.
6068e41f4b71Sopenharmony_ci
6069e41f4b71Sopenharmony_ci### onAdsBlocked<sup>12+</sup>
6070e41f4b71Sopenharmony_ci
6071e41f4b71Sopenharmony_cionAdsBlocked(callback: OnAdsBlockedCallback)
6072e41f4b71Sopenharmony_ci
6073e41f4b71Sopenharmony_ciCalled after an ad is blocked on the web page to notify the user of detailed information about the blocked ad. To reduce the frequency of notifications and minimize the impact on the page loading process, only the first notification is made when the page is fully loaded. Subsequent blocking events are reported at intervals of 1 second, and no notifications are sent if there is no ad blocked.
6074e41f4b71Sopenharmony_ci
6075e41f4b71Sopenharmony_ci**Parameters**
6076e41f4b71Sopenharmony_ci
6077e41f4b71Sopenharmony_ci| Name         | Type                                                                        | Description                   |
6078e41f4b71Sopenharmony_ci| -------------- | --------------------------------------------------------------------------- | ---------------------- |
6079e41f4b71Sopenharmony_ci| callback       | [OnAdsBlockedCallback](#onadsblockedcallback12) | Callback for **onAdsBlocked**.|
6080e41f4b71Sopenharmony_ci
6081e41f4b71Sopenharmony_ci**Example**
6082e41f4b71Sopenharmony_ci
6083e41f4b71Sopenharmony_ci  ```ts
6084e41f4b71Sopenharmony_ci  // xxx.ets
6085e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
6086e41f4b71Sopenharmony_ci
6087e41f4b71Sopenharmony_ci  @Entry
6088e41f4b71Sopenharmony_ci  @Component
6089e41f4b71Sopenharmony_ci  struct WebComponent {
6090e41f4b71Sopenharmony_ci    @State totalAdsBlockCounts: number = 0;
6091e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
6092e41f4b71Sopenharmony_ci
6093e41f4b71Sopenharmony_ci    build() {
6094e41f4b71Sopenharmony_ci      Column() {
6095e41f4b71Sopenharmony_ci        Web({ src: 'https://www.example.com', controller: this.controller })
6096e41f4b71Sopenharmony_ci        .onAdsBlocked((details: AdsBlockedDetails) => {
6097e41f4b71Sopenharmony_ci          if (details) {
6098e41f4b71Sopenharmony_ci            console.log(' Blocked ' + details.adsBlocked.length + ' in ' + details.url);
6099e41f4b71Sopenharmony_ci            let adList: Array<string> = Array.from(new Set(details.adsBlocked));
6100e41f4b71Sopenharmony_ci            this.totalAdsBlockCounts += adList.length;
6101e41f4b71Sopenharmony_ci            console.log('Total blocked counts :' + this.totalAdsBlockCounts);
6102e41f4b71Sopenharmony_ci          }
6103e41f4b71Sopenharmony_ci        })
6104e41f4b71Sopenharmony_ci      }
6105e41f4b71Sopenharmony_ci    }
6106e41f4b71Sopenharmony_ci  }
6107e41f4b71Sopenharmony_ci  ```
6108e41f4b71Sopenharmony_ci
6109e41f4b71Sopenharmony_ci## ConsoleMessage
6110e41f4b71Sopenharmony_ci
6111e41f4b71Sopenharmony_ciImplements the **ConsoleMessage** object. For the sample code, see [onConsole](#onconsole).
6112e41f4b71Sopenharmony_ci
6113e41f4b71Sopenharmony_ci### getLineNumber
6114e41f4b71Sopenharmony_ci
6115e41f4b71Sopenharmony_cigetLineNumber(): number
6116e41f4b71Sopenharmony_ci
6117e41f4b71Sopenharmony_ciObtains the number of rows in this console message.
6118e41f4b71Sopenharmony_ci
6119e41f4b71Sopenharmony_ci**Return value**
6120e41f4b71Sopenharmony_ci
6121e41f4b71Sopenharmony_ci| Type    | Description                  |
6122e41f4b71Sopenharmony_ci| ------ | -------------------- |
6123e41f4b71Sopenharmony_ci| number | Number of rows in the console message.|
6124e41f4b71Sopenharmony_ci
6125e41f4b71Sopenharmony_ci### getMessage
6126e41f4b71Sopenharmony_ci
6127e41f4b71Sopenharmony_cigetMessage(): string
6128e41f4b71Sopenharmony_ci
6129e41f4b71Sopenharmony_ciObtains the log information of this console message.
6130e41f4b71Sopenharmony_ci
6131e41f4b71Sopenharmony_ci**Return value**
6132e41f4b71Sopenharmony_ci
6133e41f4b71Sopenharmony_ci| Type    | Description                    |
6134e41f4b71Sopenharmony_ci| ------ | ---------------------- |
6135e41f4b71Sopenharmony_ci| string | Log information of the console message.|
6136e41f4b71Sopenharmony_ci
6137e41f4b71Sopenharmony_ci### getMessageLevel
6138e41f4b71Sopenharmony_ci
6139e41f4b71Sopenharmony_cigetMessageLevel(): MessageLevel
6140e41f4b71Sopenharmony_ci
6141e41f4b71Sopenharmony_ciObtains the level of this console message.
6142e41f4b71Sopenharmony_ci
6143e41f4b71Sopenharmony_ci**Return value**
6144e41f4b71Sopenharmony_ci
6145e41f4b71Sopenharmony_ci| Type                               | Description                    |
6146e41f4b71Sopenharmony_ci| --------------------------------- | ---------------------- |
6147e41f4b71Sopenharmony_ci| [MessageLevel](#messagelevel)| Level of the console message.|
6148e41f4b71Sopenharmony_ci
6149e41f4b71Sopenharmony_ci### getSourceId
6150e41f4b71Sopenharmony_ci
6151e41f4b71Sopenharmony_cigetSourceId(): string
6152e41f4b71Sopenharmony_ci
6153e41f4b71Sopenharmony_ciObtains the path and name of the web page source file.
6154e41f4b71Sopenharmony_ci
6155e41f4b71Sopenharmony_ci**Return value**
6156e41f4b71Sopenharmony_ci
6157e41f4b71Sopenharmony_ci| Type    | Description           |
6158e41f4b71Sopenharmony_ci| ------ | ------------- |
6159e41f4b71Sopenharmony_ci| string | Path and name of the web page source file.|
6160e41f4b71Sopenharmony_ci
6161e41f4b71Sopenharmony_ci## JsResult
6162e41f4b71Sopenharmony_ci
6163e41f4b71Sopenharmony_ciImplements the **JsResult** object, which indicates the result returned to the **Web** component to indicate the user operation performed in the dialog box. For the sample code, see [onAlert Event](#onalert).
6164e41f4b71Sopenharmony_ci
6165e41f4b71Sopenharmony_ci### handleCancel
6166e41f4b71Sopenharmony_ci
6167e41f4b71Sopenharmony_cihandleCancel(): void
6168e41f4b71Sopenharmony_ci
6169e41f4b71Sopenharmony_ciNotifies the **Web** component of the user's cancel operation in the dialog box.
6170e41f4b71Sopenharmony_ci
6171e41f4b71Sopenharmony_ci### handleConfirm
6172e41f4b71Sopenharmony_ci
6173e41f4b71Sopenharmony_cihandleConfirm(): void
6174e41f4b71Sopenharmony_ci
6175e41f4b71Sopenharmony_ciNotifies the **Web** component of the user's confirm operation in the dialog box.
6176e41f4b71Sopenharmony_ci
6177e41f4b71Sopenharmony_ci### handlePromptConfirm<sup>9+</sup>
6178e41f4b71Sopenharmony_ci
6179e41f4b71Sopenharmony_cihandlePromptConfirm(result: string): void
6180e41f4b71Sopenharmony_ci
6181e41f4b71Sopenharmony_ciNotifies the **Web** component of the user's confirm operation in the dialog box as well as the dialog box content.
6182e41f4b71Sopenharmony_ci
6183e41f4b71Sopenharmony_ci**Parameters**
6184e41f4b71Sopenharmony_ci
6185e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Default Value | Description       |
6186e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---- | ----------- |
6187e41f4b71Sopenharmony_ci| result | string | Yes   | -    | User input in the dialog box.|
6188e41f4b71Sopenharmony_ci
6189e41f4b71Sopenharmony_ci## FullScreenExitHandler<sup>9+</sup>
6190e41f4b71Sopenharmony_ci
6191e41f4b71Sopenharmony_ciImplements a **FullScreenExitHandler** object for listening for exiting full screen mode. For the sample code, see [onFullScreenEnter](#onfullscreenenter9).
6192e41f4b71Sopenharmony_ci
6193e41f4b71Sopenharmony_ci### constructor<sup>9+</sup>
6194e41f4b71Sopenharmony_ci
6195e41f4b71Sopenharmony_ciconstructor()
6196e41f4b71Sopenharmony_ci
6197e41f4b71Sopenharmony_ci### exitFullScreen<sup>9+</sup>
6198e41f4b71Sopenharmony_ci
6199e41f4b71Sopenharmony_ciexitFullScreen(): void
6200e41f4b71Sopenharmony_ci
6201e41f4b71Sopenharmony_ciExits full screen mode.
6202e41f4b71Sopenharmony_ci
6203e41f4b71Sopenharmony_ci## ControllerHandler<sup>9+</sup>
6204e41f4b71Sopenharmony_ci
6205e41f4b71Sopenharmony_ciImplements a **WebviewController** object for new **Web** components. For the sample code, see [onWindowNew](#onwindownew9).
6206e41f4b71Sopenharmony_ci
6207e41f4b71Sopenharmony_ci### setWebController<sup>9+</sup>
6208e41f4b71Sopenharmony_ci
6209e41f4b71Sopenharmony_cisetWebController(controller: WebviewController): void
6210e41f4b71Sopenharmony_ci
6211e41f4b71Sopenharmony_ciSets a **WebviewController** object. If opening a new window is not needed, set the parameter to **null**.
6212e41f4b71Sopenharmony_ci
6213e41f4b71Sopenharmony_ci**Parameters**
6214e41f4b71Sopenharmony_ci
6215e41f4b71Sopenharmony_ci| Name       | Type                                    | Mandatory  | Default Value | Description                                    |
6216e41f4b71Sopenharmony_ci| ---------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
6217e41f4b71Sopenharmony_ci| controller | [WebviewController](js-apis-webview.md#webviewcontroller) | Yes   | -    | **WebviewController** object of the **Web** component. If opening a new window is not needed, set it to **null**.|
6218e41f4b71Sopenharmony_ci
6219e41f4b71Sopenharmony_ci## WebResourceError
6220e41f4b71Sopenharmony_ci
6221e41f4b71Sopenharmony_ciImplements the **WebResourceError** object. For the sample code, see [onErrorReceive](#onerrorreceive).
6222e41f4b71Sopenharmony_ci
6223e41f4b71Sopenharmony_ci### getErrorCode
6224e41f4b71Sopenharmony_ci
6225e41f4b71Sopenharmony_cigetErrorCode(): number
6226e41f4b71Sopenharmony_ci
6227e41f4b71Sopenharmony_ciObtains the error code for resource loading.
6228e41f4b71Sopenharmony_ci
6229e41f4b71Sopenharmony_ci**Return value**
6230e41f4b71Sopenharmony_ci
6231e41f4b71Sopenharmony_ci| Type    | Description         |
6232e41f4b71Sopenharmony_ci| ------ | ----------- |
6233e41f4b71Sopenharmony_ci| number | Error code for resource loading. For details about error codes, see [WebNetErrorList](js-apis-netErrorList.md).|
6234e41f4b71Sopenharmony_ci
6235e41f4b71Sopenharmony_ci### getErrorInfo
6236e41f4b71Sopenharmony_ci
6237e41f4b71Sopenharmony_cigetErrorInfo(): string
6238e41f4b71Sopenharmony_ci
6239e41f4b71Sopenharmony_ciObtains error information about resource loading.
6240e41f4b71Sopenharmony_ci
6241e41f4b71Sopenharmony_ci**Return value**
6242e41f4b71Sopenharmony_ci
6243e41f4b71Sopenharmony_ci| Type    | Description          |
6244e41f4b71Sopenharmony_ci| ------ | ------------ |
6245e41f4b71Sopenharmony_ci| string | Error information about resource loading.|
6246e41f4b71Sopenharmony_ci
6247e41f4b71Sopenharmony_ci## WebResourceRequest
6248e41f4b71Sopenharmony_ci
6249e41f4b71Sopenharmony_ciImplements the **WebResourceRequest** object. For the sample code, see [onErrorReceive](#onerrorreceive).
6250e41f4b71Sopenharmony_ci
6251e41f4b71Sopenharmony_ci### getRequestHeader
6252e41f4b71Sopenharmony_ci
6253e41f4b71Sopenharmony_cigetRequestHeader(): Array\<Header\>
6254e41f4b71Sopenharmony_ci
6255e41f4b71Sopenharmony_ciObtains the information about the resource request header.
6256e41f4b71Sopenharmony_ci
6257e41f4b71Sopenharmony_ci**Return value**
6258e41f4b71Sopenharmony_ci
6259e41f4b71Sopenharmony_ci| Type                        | Description        |
6260e41f4b71Sopenharmony_ci| -------------------------- | ---------- |
6261e41f4b71Sopenharmony_ci| Array\<[Header](#header)\> | Information about the resource request header.|
6262e41f4b71Sopenharmony_ci
6263e41f4b71Sopenharmony_ci### getRequestUrl
6264e41f4b71Sopenharmony_ci
6265e41f4b71Sopenharmony_cigetRequestUrl(): string
6266e41f4b71Sopenharmony_ci
6267e41f4b71Sopenharmony_ciObtains the URL of the resource request.
6268e41f4b71Sopenharmony_ci
6269e41f4b71Sopenharmony_ci**Return value**
6270e41f4b71Sopenharmony_ci
6271e41f4b71Sopenharmony_ci| Type    | Description           |
6272e41f4b71Sopenharmony_ci| ------ | ------------- |
6273e41f4b71Sopenharmony_ci| string | URL of the resource request.|
6274e41f4b71Sopenharmony_ci
6275e41f4b71Sopenharmony_ci### isMainFrame
6276e41f4b71Sopenharmony_ci
6277e41f4b71Sopenharmony_ciisMainFrame(): boolean
6278e41f4b71Sopenharmony_ci
6279e41f4b71Sopenharmony_ciChecks whether the resource request is in the main frame.
6280e41f4b71Sopenharmony_ci
6281e41f4b71Sopenharmony_ci**Return value**
6282e41f4b71Sopenharmony_ci
6283e41f4b71Sopenharmony_ci| Type     | Description              |
6284e41f4b71Sopenharmony_ci| ------- | ---------------- |
6285e41f4b71Sopenharmony_ci| boolean | Whether the resource request is in the main frame.|
6286e41f4b71Sopenharmony_ci
6287e41f4b71Sopenharmony_ci### isRedirect
6288e41f4b71Sopenharmony_ci
6289e41f4b71Sopenharmony_ciisRedirect(): boolean
6290e41f4b71Sopenharmony_ci
6291e41f4b71Sopenharmony_ciChecks whether the resource request is redirected by the server.
6292e41f4b71Sopenharmony_ci
6293e41f4b71Sopenharmony_ci**Return value**
6294e41f4b71Sopenharmony_ci
6295e41f4b71Sopenharmony_ci| Type     | Description              |
6296e41f4b71Sopenharmony_ci| ------- | ---------------- |
6297e41f4b71Sopenharmony_ci| boolean | Whether the resource request is redirected by the server.|
6298e41f4b71Sopenharmony_ci
6299e41f4b71Sopenharmony_ci### isRequestGesture
6300e41f4b71Sopenharmony_ci
6301e41f4b71Sopenharmony_ciisRequestGesture(): boolean
6302e41f4b71Sopenharmony_ci
6303e41f4b71Sopenharmony_ciChecks whether the resource request is associated with a gesture (for example, a tap).
6304e41f4b71Sopenharmony_ci
6305e41f4b71Sopenharmony_ci**Return value**
6306e41f4b71Sopenharmony_ci
6307e41f4b71Sopenharmony_ci| Type     | Description                  |
6308e41f4b71Sopenharmony_ci| ------- | -------------------- |
6309e41f4b71Sopenharmony_ci| boolean | Whether the resource request is associated with a gesture (for example, a tap).|
6310e41f4b71Sopenharmony_ci
6311e41f4b71Sopenharmony_ci### getRequestMethod<sup>9+</sup>
6312e41f4b71Sopenharmony_ci
6313e41f4b71Sopenharmony_cigetRequestMethod(): string
6314e41f4b71Sopenharmony_ci
6315e41f4b71Sopenharmony_ciObtains the request method.
6316e41f4b71Sopenharmony_ci
6317e41f4b71Sopenharmony_ci**Return value**
6318e41f4b71Sopenharmony_ci
6319e41f4b71Sopenharmony_ci| Type    | Description     |
6320e41f4b71Sopenharmony_ci| ------ | ------- |
6321e41f4b71Sopenharmony_ci| string | Request method.|
6322e41f4b71Sopenharmony_ci
6323e41f4b71Sopenharmony_ci## Header
6324e41f4b71Sopenharmony_ci
6325e41f4b71Sopenharmony_ciDescribes the request/response header returned by the **Web** component.
6326e41f4b71Sopenharmony_ci
6327e41f4b71Sopenharmony_ci| Name         | Type    | Description           |
6328e41f4b71Sopenharmony_ci| ----------- | ------ | ------------- |
6329e41f4b71Sopenharmony_ci| headerKey   | string | Key of the request/response header.  |
6330e41f4b71Sopenharmony_ci| headerValue | string | Value of the request/response header.|
6331e41f4b71Sopenharmony_ci
6332e41f4b71Sopenharmony_ci## WebResourceResponse
6333e41f4b71Sopenharmony_ci
6334e41f4b71Sopenharmony_ciImplements the **WebResourceResponse** object. For the sample code, see [onHttpErrorReceive](#onhttperrorreceive).
6335e41f4b71Sopenharmony_ci
6336e41f4b71Sopenharmony_ci### getReasonMessage
6337e41f4b71Sopenharmony_ci
6338e41f4b71Sopenharmony_cigetReasonMessage(): string
6339e41f4b71Sopenharmony_ci
6340e41f4b71Sopenharmony_ciObtains the status code description of the resource response.
6341e41f4b71Sopenharmony_ci
6342e41f4b71Sopenharmony_ci**Return value**
6343e41f4b71Sopenharmony_ci
6344e41f4b71Sopenharmony_ci| Type    | Description           |
6345e41f4b71Sopenharmony_ci| ------ | ------------- |
6346e41f4b71Sopenharmony_ci| string | Status code description of the resource response.|
6347e41f4b71Sopenharmony_ci
6348e41f4b71Sopenharmony_ci### getResponseCode
6349e41f4b71Sopenharmony_ci
6350e41f4b71Sopenharmony_cigetResponseCode(): number
6351e41f4b71Sopenharmony_ci
6352e41f4b71Sopenharmony_ciObtains the status code of the resource response.
6353e41f4b71Sopenharmony_ci
6354e41f4b71Sopenharmony_ci**Return value**
6355e41f4b71Sopenharmony_ci
6356e41f4b71Sopenharmony_ci| Type    | Description         |
6357e41f4b71Sopenharmony_ci| ------ | ----------- |
6358e41f4b71Sopenharmony_ci| number | Status code of the resource response.|
6359e41f4b71Sopenharmony_ci
6360e41f4b71Sopenharmony_ci### getResponseData
6361e41f4b71Sopenharmony_ci
6362e41f4b71Sopenharmony_cigetResponseData(): string
6363e41f4b71Sopenharmony_ci
6364e41f4b71Sopenharmony_ciObtains the data in the resource response.
6365e41f4b71Sopenharmony_ci
6366e41f4b71Sopenharmony_ci**Return value**
6367e41f4b71Sopenharmony_ci
6368e41f4b71Sopenharmony_ci| Type    | Description       |
6369e41f4b71Sopenharmony_ci| ------ | --------- |
6370e41f4b71Sopenharmony_ci| string | Data in the resource response.|
6371e41f4b71Sopenharmony_ci
6372e41f4b71Sopenharmony_ci### getResponseEncoding
6373e41f4b71Sopenharmony_ci
6374e41f4b71Sopenharmony_cigetResponseEncoding(): string
6375e41f4b71Sopenharmony_ci
6376e41f4b71Sopenharmony_ciObtains the encoding string of the resource response.
6377e41f4b71Sopenharmony_ci
6378e41f4b71Sopenharmony_ci**Return value**
6379e41f4b71Sopenharmony_ci
6380e41f4b71Sopenharmony_ci| Type    | Description        |
6381e41f4b71Sopenharmony_ci| ------ | ---------- |
6382e41f4b71Sopenharmony_ci| string | Encoding string of the resource response.|
6383e41f4b71Sopenharmony_ci
6384e41f4b71Sopenharmony_ci### getResponseHeader
6385e41f4b71Sopenharmony_ci
6386e41f4b71Sopenharmony_cigetResponseHeader() : Array\<Header\>
6387e41f4b71Sopenharmony_ci
6388e41f4b71Sopenharmony_ciObtains the resource response header.
6389e41f4b71Sopenharmony_ci
6390e41f4b71Sopenharmony_ci**Return value**
6391e41f4b71Sopenharmony_ci
6392e41f4b71Sopenharmony_ci| Type                        | Description      |
6393e41f4b71Sopenharmony_ci| -------------------------- | -------- |
6394e41f4b71Sopenharmony_ci| Array\<[Header](#header)\> | Resource response header.|
6395e41f4b71Sopenharmony_ci
6396e41f4b71Sopenharmony_ci### getResponseMimeType
6397e41f4b71Sopenharmony_ci
6398e41f4b71Sopenharmony_cigetResponseMimeType(): string
6399e41f4b71Sopenharmony_ci
6400e41f4b71Sopenharmony_ciObtains the MIME type of the resource response.
6401e41f4b71Sopenharmony_ci
6402e41f4b71Sopenharmony_ci**Return value**
6403e41f4b71Sopenharmony_ci
6404e41f4b71Sopenharmony_ci| Type    | Description                |
6405e41f4b71Sopenharmony_ci| ------ | ------------------ |
6406e41f4b71Sopenharmony_ci| string | MIME type of the resource response.|
6407e41f4b71Sopenharmony_ci
6408e41f4b71Sopenharmony_ci### setResponseData<sup>9+</sup>
6409e41f4b71Sopenharmony_ci
6410e41f4b71Sopenharmony_cisetResponseData(data: string \| number \| Resource \| ArrayBuffer): void
6411e41f4b71Sopenharmony_ci
6412e41f4b71Sopenharmony_ciSets the data in the resource response.
6413e41f4b71Sopenharmony_ci
6414e41f4b71Sopenharmony_ci**Parameters**
6415e41f4b71Sopenharmony_ci
6416e41f4b71Sopenharmony_ci| Name | Type                                    | Mandatory  | Default Value | Description                                    |
6417e41f4b71Sopenharmony_ci| ---- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
6418e41f4b71Sopenharmony_ci| data | string \| number \| [Resource](../apis-arkui/arkui-ts/ts-types.md)<sup>10+</sup> \| ArrayBuffer<sup>11+</sup> | Yes   | -    | Resource response data to set. When set to a string, the value indicates a string in HTML format. When set to a number, the value indicates a file handle, which is closed by the system **Web** component. When set to a **Resource** object, the value indicates the file resources in the **rawfile** directory of the application. When set to a **ArrayBuffer** object, the value indicates the original binary data of a resource.|
6419e41f4b71Sopenharmony_ci
6420e41f4b71Sopenharmony_ci### setResponseEncoding<sup>9+</sup>
6421e41f4b71Sopenharmony_ci
6422e41f4b71Sopenharmony_cisetResponseEncoding(encoding: string): void
6423e41f4b71Sopenharmony_ci
6424e41f4b71Sopenharmony_ciSets the encoding string of the resource response.
6425e41f4b71Sopenharmony_ci
6426e41f4b71Sopenharmony_ci**Parameters**
6427e41f4b71Sopenharmony_ci
6428e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory  | Default Value | Description        |
6429e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---- | ------------ |
6430e41f4b71Sopenharmony_ci| encoding | string | Yes   | -    | Encoding string to set.|
6431e41f4b71Sopenharmony_ci
6432e41f4b71Sopenharmony_ci### setResponseMimeType<sup>9+</sup>
6433e41f4b71Sopenharmony_ci
6434e41f4b71Sopenharmony_cisetResponseMimeType(mimeType: string): void
6435e41f4b71Sopenharmony_ci
6436e41f4b71Sopenharmony_ciSets the MIME type of the resource response.
6437e41f4b71Sopenharmony_ci
6438e41f4b71Sopenharmony_ci**Parameters**
6439e41f4b71Sopenharmony_ci
6440e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory  | Default Value | Description                |
6441e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---- | -------------------- |
6442e41f4b71Sopenharmony_ci| mimeType | string | Yes   | -    | MIME type to set.|
6443e41f4b71Sopenharmony_ci
6444e41f4b71Sopenharmony_ci### setReasonMessage<sup>9+</sup>
6445e41f4b71Sopenharmony_ci
6446e41f4b71Sopenharmony_cisetReasonMessage(reason: string): void
6447e41f4b71Sopenharmony_ci
6448e41f4b71Sopenharmony_ciSets the status code description of the resource response.
6449e41f4b71Sopenharmony_ci
6450e41f4b71Sopenharmony_ci**Parameters**
6451e41f4b71Sopenharmony_ci
6452e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Default Value | Description           |
6453e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---- | --------------- |
6454e41f4b71Sopenharmony_ci| reason | string | Yes   | -    | Status code description to set.|
6455e41f4b71Sopenharmony_ci
6456e41f4b71Sopenharmony_ci### setResponseHeader<sup>9+</sup>
6457e41f4b71Sopenharmony_ci
6458e41f4b71Sopenharmony_cisetResponseHeader(header: Array\<Header\>): void
6459e41f4b71Sopenharmony_ci
6460e41f4b71Sopenharmony_ciSets the resource response header.
6461e41f4b71Sopenharmony_ci
6462e41f4b71Sopenharmony_ci**Parameters**
6463e41f4b71Sopenharmony_ci
6464e41f4b71Sopenharmony_ci| Name   | Type                      | Mandatory  | Default Value | Description      |
6465e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | ---- | ---------- |
6466e41f4b71Sopenharmony_ci| header | Array\<[Header](#header)\> | Yes   | -    | Resource response header to set.|
6467e41f4b71Sopenharmony_ci
6468e41f4b71Sopenharmony_ci### setResponseCode<sup>9+</sup>
6469e41f4b71Sopenharmony_ci
6470e41f4b71Sopenharmony_cisetResponseCode(code: number): void
6471e41f4b71Sopenharmony_ci
6472e41f4b71Sopenharmony_ciSets the status code of the resource response.
6473e41f4b71Sopenharmony_ci
6474e41f4b71Sopenharmony_ci**Parameters**
6475e41f4b71Sopenharmony_ci
6476e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description         |
6477e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ------------- |
6478e41f4b71Sopenharmony_ci| code | number | Yes   | -    | Status code to set.|
6479e41f4b71Sopenharmony_ci
6480e41f4b71Sopenharmony_ci### setResponseIsReady<sup>9+</sup>
6481e41f4b71Sopenharmony_ci
6482e41f4b71Sopenharmony_cisetResponseIsReady(IsReady: boolean): void
6483e41f4b71Sopenharmony_ci
6484e41f4b71Sopenharmony_ciSets whether the resource response data is ready.
6485e41f4b71Sopenharmony_ci
6486e41f4b71Sopenharmony_ci**Parameters**
6487e41f4b71Sopenharmony_ci
6488e41f4b71Sopenharmony_ci| Name    | Type   | Mandatory  | Default Value | Description         |
6489e41f4b71Sopenharmony_ci| ------- | ------- | ---- | ---- | ------------- |
6490e41f4b71Sopenharmony_ci| IsReady | boolean | Yes   | true | Whether the resource response data is ready.|
6491e41f4b71Sopenharmony_ci
6492e41f4b71Sopenharmony_ci## FileSelectorResult<sup>9+</sup>
6493e41f4b71Sopenharmony_ci
6494e41f4b71Sopenharmony_ciNotifies the **Web** component of the file selection result. For the sample code, see [onShowFileSelector](#onshowfileselector9).
6495e41f4b71Sopenharmony_ci
6496e41f4b71Sopenharmony_ci### handleFileList<sup>9+</sup>
6497e41f4b71Sopenharmony_ci
6498e41f4b71Sopenharmony_cihandleFileList(fileList: Array\<string\>): void
6499e41f4b71Sopenharmony_ci
6500e41f4b71Sopenharmony_ciInstructs the **Web** component to select a file.
6501e41f4b71Sopenharmony_ci
6502e41f4b71Sopenharmony_ci**Parameters**
6503e41f4b71Sopenharmony_ci
6504e41f4b71Sopenharmony_ci| Name     | Type           | Mandatory  | Default Value | Description        |
6505e41f4b71Sopenharmony_ci| -------- | --------------- | ---- | ---- | ------------ |
6506e41f4b71Sopenharmony_ci| fileList | Array\<string\> | Yes   | -    | List of files to operate.|
6507e41f4b71Sopenharmony_ci
6508e41f4b71Sopenharmony_ci## FileSelectorParam<sup>9+</sup>
6509e41f4b71Sopenharmony_ci
6510e41f4b71Sopenharmony_ciImplements the **FileSelectorParam** object. For the sample code, see [onShowFileSelector](#onshowfileselector9).
6511e41f4b71Sopenharmony_ci
6512e41f4b71Sopenharmony_ci### getTitle<sup>9+</sup>
6513e41f4b71Sopenharmony_ci
6514e41f4b71Sopenharmony_cigetTitle(): string
6515e41f4b71Sopenharmony_ci
6516e41f4b71Sopenharmony_ciObtains the title of this file selector.
6517e41f4b71Sopenharmony_ci
6518e41f4b71Sopenharmony_ci**Return value**
6519e41f4b71Sopenharmony_ci
6520e41f4b71Sopenharmony_ci| Type    | Description        |
6521e41f4b71Sopenharmony_ci| ------ | ---------- |
6522e41f4b71Sopenharmony_ci| string | Title of the file selector.|
6523e41f4b71Sopenharmony_ci
6524e41f4b71Sopenharmony_ci### getMode<sup>9+</sup>
6525e41f4b71Sopenharmony_ci
6526e41f4b71Sopenharmony_cigetMode(): FileSelectorMode
6527e41f4b71Sopenharmony_ci
6528e41f4b71Sopenharmony_ciObtains the mode of the file selector.
6529e41f4b71Sopenharmony_ci
6530e41f4b71Sopenharmony_ci**Return value**
6531e41f4b71Sopenharmony_ci
6532e41f4b71Sopenharmony_ci| Type                                      | Description         |
6533e41f4b71Sopenharmony_ci| ---------------------------------------- | ----------- |
6534e41f4b71Sopenharmony_ci| [FileSelectorMode](#fileselectormode9) | Mode of the file selector.|
6535e41f4b71Sopenharmony_ci
6536e41f4b71Sopenharmony_ci### getAcceptType<sup>9+</sup>
6537e41f4b71Sopenharmony_ci
6538e41f4b71Sopenharmony_cigetAcceptType(): Array\<string\>
6539e41f4b71Sopenharmony_ci
6540e41f4b71Sopenharmony_ciObtains the file filtering type.
6541e41f4b71Sopenharmony_ci
6542e41f4b71Sopenharmony_ci**Return value**
6543e41f4b71Sopenharmony_ci
6544e41f4b71Sopenharmony_ci| Type             | Description       |
6545e41f4b71Sopenharmony_ci| --------------- | --------- |
6546e41f4b71Sopenharmony_ci| Array\<string\> | File filtering type.|
6547e41f4b71Sopenharmony_ci
6548e41f4b71Sopenharmony_ci### isCapture<sup>9+</sup>
6549e41f4b71Sopenharmony_ci
6550e41f4b71Sopenharmony_ciisCapture(): boolean
6551e41f4b71Sopenharmony_ci
6552e41f4b71Sopenharmony_ciChecks whether multimedia capabilities are invoked.
6553e41f4b71Sopenharmony_ci
6554e41f4b71Sopenharmony_ci**Return value**
6555e41f4b71Sopenharmony_ci
6556e41f4b71Sopenharmony_ci| Type     | Description          |
6557e41f4b71Sopenharmony_ci| ------- | ------------ |
6558e41f4b71Sopenharmony_ci| boolean | Whether multimedia capabilities are invoked.|
6559e41f4b71Sopenharmony_ci
6560e41f4b71Sopenharmony_ci## HttpAuthHandler<sup>9+</sup>
6561e41f4b71Sopenharmony_ci
6562e41f4b71Sopenharmony_ciImplements the **HttpAuthHandler** object. For the sample code, see [onHttpAuthRequest](#onhttpauthrequest9).
6563e41f4b71Sopenharmony_ci
6564e41f4b71Sopenharmony_ci### cancel<sup>9+</sup>
6565e41f4b71Sopenharmony_ci
6566e41f4b71Sopenharmony_cicancel(): void
6567e41f4b71Sopenharmony_ci
6568e41f4b71Sopenharmony_ciCancels HTTP authentication as requested by the user.
6569e41f4b71Sopenharmony_ci
6570e41f4b71Sopenharmony_ci### confirm<sup>9+</sup>
6571e41f4b71Sopenharmony_ci
6572e41f4b71Sopenharmony_ciconfirm(userName: string, password: string): boolean
6573e41f4b71Sopenharmony_ci
6574e41f4b71Sopenharmony_ciPerforms HTTP authentication with the user name and password provided by the user.
6575e41f4b71Sopenharmony_ci
6576e41f4b71Sopenharmony_ci**Parameters**
6577e41f4b71Sopenharmony_ci
6578e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory  | Default Value | Description      |
6579e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---- | ---------- |
6580e41f4b71Sopenharmony_ci| userName | string | Yes   | -    | HTTP authentication user name.|
6581e41f4b71Sopenharmony_ci| password      | string | Yes   | -    | HTTP authentication password. |
6582e41f4b71Sopenharmony_ci
6583e41f4b71Sopenharmony_ci**Return value**
6584e41f4b71Sopenharmony_ci
6585e41f4b71Sopenharmony_ci| Type     | Description                   |
6586e41f4b71Sopenharmony_ci| ------- | --------------------- |
6587e41f4b71Sopenharmony_ci| boolean | Returns **true** if the authentication is successful; returns **false** otherwise.|
6588e41f4b71Sopenharmony_ci
6589e41f4b71Sopenharmony_ci### isHttpAuthInfoSaved<sup>9+</sup>
6590e41f4b71Sopenharmony_ci
6591e41f4b71Sopenharmony_ciisHttpAuthInfoSaved(): boolean
6592e41f4b71Sopenharmony_ci
6593e41f4b71Sopenharmony_ciSets whether to use the account name and password cached on the server for authentication.
6594e41f4b71Sopenharmony_ci
6595e41f4b71Sopenharmony_ci**Return value**
6596e41f4b71Sopenharmony_ci
6597e41f4b71Sopenharmony_ci| Type     | Description                       |
6598e41f4b71Sopenharmony_ci| ------- | ------------------------- |
6599e41f4b71Sopenharmony_ci| boolean | Returns **true** if the authentication is successful; returns **false** otherwise.|
6600e41f4b71Sopenharmony_ci
6601e41f4b71Sopenharmony_ci## SslErrorHandler<sup>9+</sup>
6602e41f4b71Sopenharmony_ci
6603e41f4b71Sopenharmony_ciImplements an **SslErrorHandler** object. For the sample code, see [onSslErrorEventReceive Event](#onsslerroreventreceive9).
6604e41f4b71Sopenharmony_ci
6605e41f4b71Sopenharmony_ci### handleCancel<sup>9+</sup>
6606e41f4b71Sopenharmony_ci
6607e41f4b71Sopenharmony_cihandleCancel(): void
6608e41f4b71Sopenharmony_ci
6609e41f4b71Sopenharmony_ciCancels this request.
6610e41f4b71Sopenharmony_ci
6611e41f4b71Sopenharmony_ci### handleConfirm<sup>9+</sup>
6612e41f4b71Sopenharmony_ci
6613e41f4b71Sopenharmony_cihandleConfirm(): void
6614e41f4b71Sopenharmony_ci
6615e41f4b71Sopenharmony_ciContinues using the SSL certificate.
6616e41f4b71Sopenharmony_ci
6617e41f4b71Sopenharmony_ci## ClientAuthenticationHandler<sup>9+</sup>
6618e41f4b71Sopenharmony_ci
6619e41f4b71Sopenharmony_ciImplements a **ClientAuthenticationHandler** object returned by the **Web** component. For the sample code, see [onClientAuthenticationRequest](#onclientauthenticationrequest9).
6620e41f4b71Sopenharmony_ci
6621e41f4b71Sopenharmony_ci### confirm<sup>9+</sup>
6622e41f4b71Sopenharmony_ci
6623e41f4b71Sopenharmony_ciconfirm(priKeyFile : string, certChainFile : string): void
6624e41f4b71Sopenharmony_ci
6625e41f4b71Sopenharmony_ciUses the specified private key and client certificate chain.
6626e41f4b71Sopenharmony_ci
6627e41f4b71Sopenharmony_ci**Parameters**
6628e41f4b71Sopenharmony_ci
6629e41f4b71Sopenharmony_ci| Name          | Type  | Mandatory  | Description              |
6630e41f4b71Sopenharmony_ci| ------------- | ------ | ---- | ------------------ |
6631e41f4b71Sopenharmony_ci| priKeyFile    | string | Yes   | File that stores the private key, which is a directory including the file name. |
6632e41f4b71Sopenharmony_ci| certChainFile | string | Yes   | File that stores the certificate chain, which is a directory including the file name.|
6633e41f4b71Sopenharmony_ci
6634e41f4b71Sopenharmony_ci### confirm<sup>10+</sup>
6635e41f4b71Sopenharmony_ci
6636e41f4b71Sopenharmony_ciconfirm(authUri : string): void
6637e41f4b71Sopenharmony_ci
6638e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
6639e41f4b71Sopenharmony_ci
6640e41f4b71Sopenharmony_ciInstructs the **Web** component to use the specified credentials (obtained from the certificate management module).
6641e41f4b71Sopenharmony_ci
6642e41f4b71Sopenharmony_ci**Parameters**
6643e41f4b71Sopenharmony_ci
6644e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory  | Description   |
6645e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ------- |
6646e41f4b71Sopenharmony_ci| authUri | string | Yes   | Key value of the credentials.|
6647e41f4b71Sopenharmony_ci
6648e41f4b71Sopenharmony_ci### cancel<sup>9+</sup>
6649e41f4b71Sopenharmony_ci
6650e41f4b71Sopenharmony_cicancel(): void
6651e41f4b71Sopenharmony_ci
6652e41f4b71Sopenharmony_ciCancels the client certificate request sent by the same host and port server. No additional event will be reported for requests from the same host and port server.
6653e41f4b71Sopenharmony_ci
6654e41f4b71Sopenharmony_ci### ignore<sup>9+</sup>
6655e41f4b71Sopenharmony_ci
6656e41f4b71Sopenharmony_ciignore(): void
6657e41f4b71Sopenharmony_ci
6658e41f4b71Sopenharmony_ciIgnores this request.
6659e41f4b71Sopenharmony_ci
6660e41f4b71Sopenharmony_ci## PermissionRequest<sup>9+</sup>
6661e41f4b71Sopenharmony_ci
6662e41f4b71Sopenharmony_ciImplements the **PermissionRequest** object. For the sample code, see [onPermissionRequest](#onpermissionrequest9).
6663e41f4b71Sopenharmony_ci
6664e41f4b71Sopenharmony_ci### deny<sup>9+</sup>
6665e41f4b71Sopenharmony_ci
6666e41f4b71Sopenharmony_cideny(): void
6667e41f4b71Sopenharmony_ci
6668e41f4b71Sopenharmony_ciDenies the permission requested by the web page.
6669e41f4b71Sopenharmony_ci
6670e41f4b71Sopenharmony_ci### getOrigin<sup>9+</sup>
6671e41f4b71Sopenharmony_ci
6672e41f4b71Sopenharmony_cigetOrigin(): string
6673e41f4b71Sopenharmony_ci
6674e41f4b71Sopenharmony_ciObtains the origin of this web page.
6675e41f4b71Sopenharmony_ci
6676e41f4b71Sopenharmony_ci**Return value**
6677e41f4b71Sopenharmony_ci
6678e41f4b71Sopenharmony_ci| Type    | Description          |
6679e41f4b71Sopenharmony_ci| ------ | ------------ |
6680e41f4b71Sopenharmony_ci| string | Origin of the web page that requests the permission.|
6681e41f4b71Sopenharmony_ci
6682e41f4b71Sopenharmony_ci### getAccessibleResource<sup>9+</sup>
6683e41f4b71Sopenharmony_ci
6684e41f4b71Sopenharmony_cigetAccessibleResource(): Array\<string\>
6685e41f4b71Sopenharmony_ci
6686e41f4b71Sopenharmony_ciObtains the list of accessible resources requested for the web page. For details about the resource types, see [ProtectedResourceType](#protectedresourcetype9).
6687e41f4b71Sopenharmony_ci
6688e41f4b71Sopenharmony_ci**Return value**
6689e41f4b71Sopenharmony_ci
6690e41f4b71Sopenharmony_ci| Type             | Description           |
6691e41f4b71Sopenharmony_ci| --------------- | ------------- |
6692e41f4b71Sopenharmony_ci| Array\<string\> | List of accessible resources requested by the web page.|
6693e41f4b71Sopenharmony_ci
6694e41f4b71Sopenharmony_ci### grant<sup>9+</sup>
6695e41f4b71Sopenharmony_ci
6696e41f4b71Sopenharmony_cigrant(resources: Array\<string\>): void
6697e41f4b71Sopenharmony_ci
6698e41f4b71Sopenharmony_ciGrants the permission for resources requested by the web page.
6699e41f4b71Sopenharmony_ci
6700e41f4b71Sopenharmony_ci**Parameters**
6701e41f4b71Sopenharmony_ci
6702e41f4b71Sopenharmony_ci| Name      | Type           | Mandatory  | Default Value | Description           |
6703e41f4b71Sopenharmony_ci| --------- | --------------- | ---- | ---- | --------------- |
6704e41f4b71Sopenharmony_ci| resources | Array\<string\> | Yes   | -    | List of resources that can be requested by the web page with the permission to grant.|
6705e41f4b71Sopenharmony_ci
6706e41f4b71Sopenharmony_ci## ScreenCaptureHandler<sup>10+</sup>
6707e41f4b71Sopenharmony_ci
6708e41f4b71Sopenharmony_ciImplements the **ScreenCaptureHandler** object for accepting or rejecting a screen capture request. For the sample code, see [onScreenCaptureRequest Event](#onscreencapturerequest10).
6709e41f4b71Sopenharmony_ci
6710e41f4b71Sopenharmony_ci### deny<sup>10+</sup>
6711e41f4b71Sopenharmony_ci
6712e41f4b71Sopenharmony_cideny(): void
6713e41f4b71Sopenharmony_ci
6714e41f4b71Sopenharmony_ciRejects this screen capture request.
6715e41f4b71Sopenharmony_ci
6716e41f4b71Sopenharmony_ci### getOrigin<sup>10+</sup>
6717e41f4b71Sopenharmony_ci
6718e41f4b71Sopenharmony_cigetOrigin(): string
6719e41f4b71Sopenharmony_ci
6720e41f4b71Sopenharmony_ciObtains the origin of this web page.
6721e41f4b71Sopenharmony_ci
6722e41f4b71Sopenharmony_ci**Return value**
6723e41f4b71Sopenharmony_ci
6724e41f4b71Sopenharmony_ci| Type    | Description          |
6725e41f4b71Sopenharmony_ci| ------ | ------------ |
6726e41f4b71Sopenharmony_ci| string | Origin of the web page that requests the permission.|
6727e41f4b71Sopenharmony_ci
6728e41f4b71Sopenharmony_ci### grant<sup>10+</sup>
6729e41f4b71Sopenharmony_ci
6730e41f4b71Sopenharmony_cigrant(config: ScreenCaptureConfig): void
6731e41f4b71Sopenharmony_ci
6732e41f4b71Sopenharmony_ci**Required permissions:** ohos.permission.MICROPHONE
6733e41f4b71Sopenharmony_ci
6734e41f4b71Sopenharmony_ciGrants the screen capture permission.
6735e41f4b71Sopenharmony_ci
6736e41f4b71Sopenharmony_ci**Parameters**
6737e41f4b71Sopenharmony_ci
6738e41f4b71Sopenharmony_ci| Name   | Type                                    | Mandatory  | Default Value | Description   |
6739e41f4b71Sopenharmony_ci| ------ | ---------------------------------------- | ---- | ---- | ------- |
6740e41f4b71Sopenharmony_ci| config | [ScreenCaptureConfig](#screencaptureconfig10) | Yes   | -    | Screen capture configuration.|
6741e41f4b71Sopenharmony_ci
6742e41f4b71Sopenharmony_ci## EventResult<sup>12+</sup>
6743e41f4b71Sopenharmony_ci
6744e41f4b71Sopenharmony_ciRepresents the event consumption result sent to the **Web** component. For details about the supported events, see [TouchType](../apis-arkui/arkui-ts/ts-appendix-enums.md#touchtype). If the application does not consume the event, set this parameter to **false**, and the event will be consumed by the **Web** component. If the application has consumed the event, set this parameter to **true**, and the event will not be consumed by the **Web** component. For the sample code, see [onNativeEmbedGestureEvent](#onnativeembedgestureevent11).
6745e41f4b71Sopenharmony_ci
6746e41f4b71Sopenharmony_ci### setGestureEventResult<sup>12+</sup>
6747e41f4b71Sopenharmony_ci
6748e41f4b71Sopenharmony_cisetGestureEventResult(result: boolean): void
6749e41f4b71Sopenharmony_ci
6750e41f4b71Sopenharmony_ci**Parameters**
6751e41f4b71Sopenharmony_ci
6752e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory  | Description   |
6753e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ------- |
6754e41f4b71Sopenharmony_ci| result | boolean | Yes   | Whether to consume the gesture event.|
6755e41f4b71Sopenharmony_ci
6756e41f4b71Sopenharmony_ci**Example**
6757e41f4b71Sopenharmony_ci
6758e41f4b71Sopenharmony_ciSee [onNativeEmbedGestureEvent](#onnativeembedgestureevent11).
6759e41f4b71Sopenharmony_ci
6760e41f4b71Sopenharmony_ci## ContextMenuSourceType<sup>9+</sup>
6761e41f4b71Sopenharmony_ci
6762e41f4b71Sopenharmony_ci| Name      | Value| Description        |
6763e41f4b71Sopenharmony_ci| --------- | -- |------------ |
6764e41f4b71Sopenharmony_ci| None      | 0 | Other event sources.|
6765e41f4b71Sopenharmony_ci| Mouse     | 1 | Mouse event.  |
6766e41f4b71Sopenharmony_ci| LongPress | 2 | Long press event.  |
6767e41f4b71Sopenharmony_ci
6768e41f4b71Sopenharmony_ci## ContextMenuMediaType<sup>9+</sup>
6769e41f4b71Sopenharmony_ci
6770e41f4b71Sopenharmony_ci| Name   | Value| Description           |
6771e41f4b71Sopenharmony_ci| ----- | -- | ------------- |
6772e41f4b71Sopenharmony_ci| None  | 0 | Non-special media or other media types.|
6773e41f4b71Sopenharmony_ci| Image | 1 | Image.          |
6774e41f4b71Sopenharmony_ci
6775e41f4b71Sopenharmony_ci## ContextMenuInputFieldType<sup>9+</sup>
6776e41f4b71Sopenharmony_ci
6777e41f4b71Sopenharmony_ci| Name       | Value| Description                         |
6778e41f4b71Sopenharmony_ci| --------- | -- | --------------------------- |
6779e41f4b71Sopenharmony_ci| None      | 0 | Non-input field.                      |
6780e41f4b71Sopenharmony_ci| PlainText | 1 | Plain text field, such as the text, search, or email field.|
6781e41f4b71Sopenharmony_ci| Password  | 2 | Password field.                      |
6782e41f4b71Sopenharmony_ci| Number    | 3 | Numeric field.                      |
6783e41f4b71Sopenharmony_ci| Telephone | 4 | Phone number field.                    |
6784e41f4b71Sopenharmony_ci| Other     | 5 | Field of any other type.                      |
6785e41f4b71Sopenharmony_ci
6786e41f4b71Sopenharmony_ci## ContextMenuEditStateFlags<sup>9+</sup>
6787e41f4b71Sopenharmony_ci
6788e41f4b71Sopenharmony_ciSupports using with a bitwise OR operator. For example, to support CAN_CUT, CAN_COPY, and CAN_SELECT_ALL at the same time, use CAN_CUT | CAN_COPY | CAN_SELECT_ALL or 11.
6789e41f4b71Sopenharmony_ci
6790e41f4b71Sopenharmony_ci| Name           | Value| Description    |
6791e41f4b71Sopenharmony_ci| -------------- | -- | -------- |
6792e41f4b71Sopenharmony_ci| NONE           | 0 | Editing is not allowed.|
6793e41f4b71Sopenharmony_ci| CAN_CUT        | 1 | The cut operation is allowed.|
6794e41f4b71Sopenharmony_ci| CAN_COPY       | 2 | The copy operation is allowed.|
6795e41f4b71Sopenharmony_ci| CAN_PASTE      | 4 | The paste operation is allowed.|
6796e41f4b71Sopenharmony_ci| CAN_SELECT_ALL | 8 | The select all operation is allowed.|
6797e41f4b71Sopenharmony_ci
6798e41f4b71Sopenharmony_ci## WebContextMenuParam<sup>9+</sup>
6799e41f4b71Sopenharmony_ci
6800e41f4b71Sopenharmony_ciImplements a context menu, which is displayed after the user clicks the right mouse button or long presses a specific element, such as an image or a link. For the sample code, see [onContextMenuShow](#oncontextmenushow9).
6801e41f4b71Sopenharmony_ci
6802e41f4b71Sopenharmony_ci### x<sup>9+</sup>
6803e41f4b71Sopenharmony_ci
6804e41f4b71Sopenharmony_cix(): number
6805e41f4b71Sopenharmony_ci
6806e41f4b71Sopenharmony_ciObtains the X coordinate of the context menu.
6807e41f4b71Sopenharmony_ci
6808e41f4b71Sopenharmony_ci**Return value**
6809e41f4b71Sopenharmony_ci
6810e41f4b71Sopenharmony_ci| Type    | Description                |
6811e41f4b71Sopenharmony_ci| ------ | ------------------ |
6812e41f4b71Sopenharmony_ci| number | If the display is normal, a non-negative integer is returned. Otherwise, **-1** is returned.|
6813e41f4b71Sopenharmony_ci
6814e41f4b71Sopenharmony_ci### y<sup>9+</sup>
6815e41f4b71Sopenharmony_ci
6816e41f4b71Sopenharmony_ciy(): number
6817e41f4b71Sopenharmony_ci
6818e41f4b71Sopenharmony_ciObtains the Y coordinate of the context menu.
6819e41f4b71Sopenharmony_ci
6820e41f4b71Sopenharmony_ci**Return value**
6821e41f4b71Sopenharmony_ci
6822e41f4b71Sopenharmony_ci| Type    | Description                |
6823e41f4b71Sopenharmony_ci| ------ | ------------------ |
6824e41f4b71Sopenharmony_ci| number | If the display is normal, a non-negative integer is returned. Otherwise, **-1** is returned.|
6825e41f4b71Sopenharmony_ci
6826e41f4b71Sopenharmony_ci### getLinkUrl<sup>9+</sup>
6827e41f4b71Sopenharmony_ci
6828e41f4b71Sopenharmony_cigetLinkUrl(): string
6829e41f4b71Sopenharmony_ci
6830e41f4b71Sopenharmony_ciObtains the URL of the destination link.
6831e41f4b71Sopenharmony_ci
6832e41f4b71Sopenharmony_ci**Return value**
6833e41f4b71Sopenharmony_ci
6834e41f4b71Sopenharmony_ci| Type    | Description                       |
6835e41f4b71Sopenharmony_ci| ------ | ------------------------- |
6836e41f4b71Sopenharmony_ci| string | If it is a link that is being long pressed, the URL that has passed the security check is returned.|
6837e41f4b71Sopenharmony_ci
6838e41f4b71Sopenharmony_ci### getUnfilteredLinkUrl<sup>9+</sup>
6839e41f4b71Sopenharmony_ci
6840e41f4b71Sopenharmony_cigetUnfilteredLinkUrl(): string
6841e41f4b71Sopenharmony_ci
6842e41f4b71Sopenharmony_ciObtains the URL of the destination link.
6843e41f4b71Sopenharmony_ci
6844e41f4b71Sopenharmony_ci**Return value**
6845e41f4b71Sopenharmony_ci
6846e41f4b71Sopenharmony_ci| Type    | Description                   |
6847e41f4b71Sopenharmony_ci| ------ | --------------------- |
6848e41f4b71Sopenharmony_ci| string | If it is a link that is being long pressed, the original URL is returned.|
6849e41f4b71Sopenharmony_ci
6850e41f4b71Sopenharmony_ci### getSourceUrl<sup>9+</sup>
6851e41f4b71Sopenharmony_ci
6852e41f4b71Sopenharmony_cigetSourceUrl(): string
6853e41f4b71Sopenharmony_ci
6854e41f4b71Sopenharmony_ciObtain the source URL.
6855e41f4b71Sopenharmony_ci
6856e41f4b71Sopenharmony_ci**Return value**
6857e41f4b71Sopenharmony_ci
6858e41f4b71Sopenharmony_ci| Type    | Description                      |
6859e41f4b71Sopenharmony_ci| ------ | ------------------------ |
6860e41f4b71Sopenharmony_ci| string | If the selected element has the **src** attribute, the URL in the **src** is returned.|
6861e41f4b71Sopenharmony_ci
6862e41f4b71Sopenharmony_ci### existsImageContents<sup>9+</sup>
6863e41f4b71Sopenharmony_ci
6864e41f4b71Sopenharmony_ciexistsImageContents(): boolean
6865e41f4b71Sopenharmony_ci
6866e41f4b71Sopenharmony_ciChecks whether image content exists.
6867e41f4b71Sopenharmony_ci
6868e41f4b71Sopenharmony_ci**Return value**
6869e41f4b71Sopenharmony_ci
6870e41f4b71Sopenharmony_ci| Type     | Description                       |
6871e41f4b71Sopenharmony_ci| ------- | ------------------------- |
6872e41f4b71Sopenharmony_ci| boolean | The value **true** means that there is image content in the element being long pressed, and **false** means the opposite.|
6873e41f4b71Sopenharmony_ci
6874e41f4b71Sopenharmony_ci### getMediaType<sup>9+</sup>
6875e41f4b71Sopenharmony_ci
6876e41f4b71Sopenharmony_cigetMediaType(): ContextMenuMediaType
6877e41f4b71Sopenharmony_ci
6878e41f4b71Sopenharmony_ciObtains the media type of this web page element.
6879e41f4b71Sopenharmony_ci
6880e41f4b71Sopenharmony_ci**Return value**
6881e41f4b71Sopenharmony_ci
6882e41f4b71Sopenharmony_ci| Type                                      | Description       |
6883e41f4b71Sopenharmony_ci| ---------------------------------------- | --------- |
6884e41f4b71Sopenharmony_ci| [ContextMenuMediaType](#contextmenumediatype9) | Media type of the web page element.|
6885e41f4b71Sopenharmony_ci
6886e41f4b71Sopenharmony_ci### getSelectionText<sup>9+</sup>
6887e41f4b71Sopenharmony_ci
6888e41f4b71Sopenharmony_cigetSelectionText(): string
6889e41f4b71Sopenharmony_ci
6890e41f4b71Sopenharmony_ciObtains the selected text.
6891e41f4b71Sopenharmony_ci
6892e41f4b71Sopenharmony_ci**Return value**
6893e41f4b71Sopenharmony_ci
6894e41f4b71Sopenharmony_ci| Type    | Description                  |
6895e41f4b71Sopenharmony_ci| ------ | -------------------- |
6896e41f4b71Sopenharmony_ci| string | Selected text for the context menu. If no text is selected, null is returned.|
6897e41f4b71Sopenharmony_ci
6898e41f4b71Sopenharmony_ci### getSourceType<sup>9+</sup>
6899e41f4b71Sopenharmony_ci
6900e41f4b71Sopenharmony_cigetSourceType(): ContextMenuSourceType
6901e41f4b71Sopenharmony_ci
6902e41f4b71Sopenharmony_ciObtains the event source of the context menu.
6903e41f4b71Sopenharmony_ci
6904e41f4b71Sopenharmony_ci**Return value**
6905e41f4b71Sopenharmony_ci
6906e41f4b71Sopenharmony_ci| Type                                      | Description     |
6907e41f4b71Sopenharmony_ci| ---------------------------------------- | ------- |
6908e41f4b71Sopenharmony_ci| [ContextMenuSourceType](#contextmenusourcetype9) | Event source of the context menu.|
6909e41f4b71Sopenharmony_ci
6910e41f4b71Sopenharmony_ci### getInputFieldType<sup>9+</sup>
6911e41f4b71Sopenharmony_ci
6912e41f4b71Sopenharmony_cigetInputFieldType(): ContextMenuInputFieldType
6913e41f4b71Sopenharmony_ci
6914e41f4b71Sopenharmony_ciObtains the input field type of this web page element.
6915e41f4b71Sopenharmony_ci
6916e41f4b71Sopenharmony_ci**Return value**
6917e41f4b71Sopenharmony_ci
6918e41f4b71Sopenharmony_ci| Type                                      | Description    |
6919e41f4b71Sopenharmony_ci| ---------------------------------------- | ------ |
6920e41f4b71Sopenharmony_ci| [ContextMenuInputFieldType](#contextmenuinputfieldtype9) | Input field type.|
6921e41f4b71Sopenharmony_ci
6922e41f4b71Sopenharmony_ci### isEditable<sup>9+</sup>
6923e41f4b71Sopenharmony_ci
6924e41f4b71Sopenharmony_ciisEditable(): boolean
6925e41f4b71Sopenharmony_ci
6926e41f4b71Sopenharmony_ciChecks whether this web page element is editable.
6927e41f4b71Sopenharmony_ci
6928e41f4b71Sopenharmony_ci**Return value**
6929e41f4b71Sopenharmony_ci
6930e41f4b71Sopenharmony_ci| Type     | Description                        |
6931e41f4b71Sopenharmony_ci| ------- | -------------------------- |
6932e41f4b71Sopenharmony_ci| boolean | Returns **true** if the web page element is editable; returns **false** otherwise.|
6933e41f4b71Sopenharmony_ci
6934e41f4b71Sopenharmony_ci### getEditStateFlags<sup>9+</sup>
6935e41f4b71Sopenharmony_ci
6936e41f4b71Sopenharmony_cigetEditStateFlags(): number
6937e41f4b71Sopenharmony_ci
6938e41f4b71Sopenharmony_ciObtains the edit state flag of this web page element.
6939e41f4b71Sopenharmony_ci
6940e41f4b71Sopenharmony_ci**Return value**
6941e41f4b71Sopenharmony_ci
6942e41f4b71Sopenharmony_ci| Type    | Description                                      |
6943e41f4b71Sopenharmony_ci| ------ | ---------------------------------------- |
6944e41f4b71Sopenharmony_ci| number | Edit state flag of the web page element. For details, see [ContextMenuEditStateFlags](#contextmenueditstateflags9).|
6945e41f4b71Sopenharmony_ci
6946e41f4b71Sopenharmony_ci## WebContextMenuResult<sup>9+</sup>
6947e41f4b71Sopenharmony_ci
6948e41f4b71Sopenharmony_ciImplements a **WebContextMenuResult** object. For the sample code, see [onContextMenuShow](#oncontextmenushow9).
6949e41f4b71Sopenharmony_ci
6950e41f4b71Sopenharmony_ci### closeContextMenu<sup>9+</sup>
6951e41f4b71Sopenharmony_ci
6952e41f4b71Sopenharmony_cicloseContextMenu(): void
6953e41f4b71Sopenharmony_ci
6954e41f4b71Sopenharmony_ciCloses this context menu. This API must be called when no operations in **WebContextMenuResult** are performed.
6955e41f4b71Sopenharmony_ci
6956e41f4b71Sopenharmony_ci### copyImage<sup>9+</sup>
6957e41f4b71Sopenharmony_ci
6958e41f4b71Sopenharmony_cicopyImage(): void
6959e41f4b71Sopenharmony_ci
6960e41f4b71Sopenharmony_ciCopies the image specified in **WebContextMenuParam**.
6961e41f4b71Sopenharmony_ci
6962e41f4b71Sopenharmony_ci### copy<sup>9+</sup>
6963e41f4b71Sopenharmony_ci
6964e41f4b71Sopenharmony_cicopy(): void
6965e41f4b71Sopenharmony_ci
6966e41f4b71Sopenharmony_ciCopies text related to this context menu.
6967e41f4b71Sopenharmony_ci
6968e41f4b71Sopenharmony_ci### paste<sup>9+</sup>
6969e41f4b71Sopenharmony_ci
6970e41f4b71Sopenharmony_cipaste(): void
6971e41f4b71Sopenharmony_ci
6972e41f4b71Sopenharmony_ciPerforms the paste operation related to this context menu.
6973e41f4b71Sopenharmony_ci
6974e41f4b71Sopenharmony_ci### cut<sup>9+</sup>
6975e41f4b71Sopenharmony_ci
6976e41f4b71Sopenharmony_cicut(): void
6977e41f4b71Sopenharmony_ci
6978e41f4b71Sopenharmony_ciPerforms the cut operation related to this context menu.
6979e41f4b71Sopenharmony_ci
6980e41f4b71Sopenharmony_ci### selectAll<sup>9+</sup>
6981e41f4b71Sopenharmony_ci
6982e41f4b71Sopenharmony_ciselectAll(): void
6983e41f4b71Sopenharmony_ci
6984e41f4b71Sopenharmony_ciPerforms the select all operation related to this context menu.
6985e41f4b71Sopenharmony_ci
6986e41f4b71Sopenharmony_ci## JsGeolocation
6987e41f4b71Sopenharmony_ci
6988e41f4b71Sopenharmony_ciImplements the **PermissionRequest** object. For the sample code, see [onGeolocationShow Event](#ongeolocationshow).
6989e41f4b71Sopenharmony_ci
6990e41f4b71Sopenharmony_ci### constructor
6991e41f4b71Sopenharmony_ci
6992e41f4b71Sopenharmony_ciconstructor()
6993e41f4b71Sopenharmony_ci
6994e41f4b71Sopenharmony_ci### invoke
6995e41f4b71Sopenharmony_ci
6996e41f4b71Sopenharmony_ciinvoke(origin: string, allow: boolean, retain: boolean): void
6997e41f4b71Sopenharmony_ci
6998e41f4b71Sopenharmony_ciSets the geolocation permission status of a web page.
6999e41f4b71Sopenharmony_ci
7000e41f4b71Sopenharmony_ci**Parameters**
7001e41f4b71Sopenharmony_ci
7002e41f4b71Sopenharmony_ci| Name   | Type   | Mandatory  | Default Value | Description                                    |
7003e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ---- | ---------------------------------------- |
7004e41f4b71Sopenharmony_ci| origin | string  | Yes   | -    | Index of the origin.                              |
7005e41f4b71Sopenharmony_ci| allow  | boolean | Yes   | -    | Geolocation permission status.                            |
7006e41f4b71Sopenharmony_ci| retain | boolean | Yes   | -    | Whether the geolocation permission status can be saved to the system. You can manage the geolocation permissions saved to the system through [GeolocationPermissions<sup>9+</sup>](js-apis-webview.md#geolocationpermissions).|
7007e41f4b71Sopenharmony_ci
7008e41f4b71Sopenharmony_ci## MessageLevel
7009e41f4b71Sopenharmony_ci
7010e41f4b71Sopenharmony_ci| Name   | Value| Description   |
7011e41f4b71Sopenharmony_ci| ----- | -- | ---- |
7012e41f4b71Sopenharmony_ci| Debug | 1 | Debug level.|
7013e41f4b71Sopenharmony_ci| Error | 4 | Error level.|
7014e41f4b71Sopenharmony_ci| Info  | 2 | Information level.|
7015e41f4b71Sopenharmony_ci| Log   | 5 | Log level.|
7016e41f4b71Sopenharmony_ci| Warn  | 3 | Warning level.|
7017e41f4b71Sopenharmony_ci
7018e41f4b71Sopenharmony_ci## RenderExitReason<sup>9+</sup>
7019e41f4b71Sopenharmony_ci
7020e41f4b71Sopenharmony_ciEnumerates the reasons why the rendering process exits.
7021e41f4b71Sopenharmony_ci
7022e41f4b71Sopenharmony_ci| Name                        | Value| Description               |
7023e41f4b71Sopenharmony_ci| -------------------------- | -- | ----------------- |
7024e41f4b71Sopenharmony_ci| ProcessAbnormalTermination | 0 | The rendering process exits abnormally.        |
7025e41f4b71Sopenharmony_ci| ProcessWasKilled           | 1 | The rendering process receives a SIGKILL message or is manually terminated.|
7026e41f4b71Sopenharmony_ci| ProcessCrashed             | 2 | The rendering process crashes due to segmentation or other errors.   |
7027e41f4b71Sopenharmony_ci| ProcessOom                 | 3 | The program memory is running low.          |
7028e41f4b71Sopenharmony_ci| ProcessExitUnknown         | 4 | Other reason.            |
7029e41f4b71Sopenharmony_ci
7030e41f4b71Sopenharmony_ci## MixedMode
7031e41f4b71Sopenharmony_ci
7032e41f4b71Sopenharmony_ci| Name       | Value| Description                                |
7033e41f4b71Sopenharmony_ci| ---------- | -- | ---------------------------------- |
7034e41f4b71Sopenharmony_ci| All        | 0 | HTTP and HTTPS hybrid content can be loaded. This means that all insecure content can be loaded.|
7035e41f4b71Sopenharmony_ci| Compatible | 1 | HTTP and HTTPS hybrid content can be loaded in compatibility mode. This means that some insecure content may be loaded.          |
7036e41f4b71Sopenharmony_ci| None       | 2 | HTTP and HTTPS hybrid content cannot be loaded.              |
7037e41f4b71Sopenharmony_ci
7038e41f4b71Sopenharmony_ci## CacheMode<sup>9+</sup>
7039e41f4b71Sopenharmony_ci
7040e41f4b71Sopenharmony_ci| Name     | Value| Description                                  |
7041e41f4b71Sopenharmony_ci| ------- | -- | ------------------------------------ |
7042e41f4b71Sopenharmony_ci| Default | 0 | The cache that has not expired is used to load the resources. If the resources do not exist in the cache, they will be obtained from the Internet.|
7043e41f4b71Sopenharmony_ci| None    | 1 | The cache is used to load the resources. If the resources do not exist in the cache, they will be obtained from the Internet.    |
7044e41f4b71Sopenharmony_ci| Online  | 2 | The cache is not used to load the resources. All resources are obtained from the Internet.              |
7045e41f4b71Sopenharmony_ci| Only    | 3 | The cache alone is used to load the resources.                       |
7046e41f4b71Sopenharmony_ci
7047e41f4b71Sopenharmony_ci## FileSelectorMode<sup>9+</sup>
7048e41f4b71Sopenharmony_ci
7049e41f4b71Sopenharmony_ci| Name                  | Value| Description        |
7050e41f4b71Sopenharmony_ci| -------------------- | -- | ---------- |
7051e41f4b71Sopenharmony_ci| FileOpenMode         | 0 | Open and upload a file. |
7052e41f4b71Sopenharmony_ci| FileOpenMultipleMode | 1 | Open and upload multiple files. |
7053e41f4b71Sopenharmony_ci| FileOpenFolderMode   | 2 | Open and upload a folder.|
7054e41f4b71Sopenharmony_ci| FileSaveMode         | 3 | Save a file.   |
7055e41f4b71Sopenharmony_ci
7056e41f4b71Sopenharmony_ci ## HitTestType
7057e41f4b71Sopenharmony_ci
7058e41f4b71Sopenharmony_ci| Name           | Value| Description                      |
7059e41f4b71Sopenharmony_ci| ------------- | -- | ------------------------ |
7060e41f4b71Sopenharmony_ci| EditText      | 0 | Editable area.                 |
7061e41f4b71Sopenharmony_ci| Email         | 1 | Email address.                 |
7062e41f4b71Sopenharmony_ci| HttpAnchor    | 2 | Hyperlink whose **src** is **http**.          |
7063e41f4b71Sopenharmony_ci| HttpAnchorImg | 3 | Image with a hyperlink, where **src** is **http**.|
7064e41f4b71Sopenharmony_ci| Img           | 4 | HTML::img tag.            |
7065e41f4b71Sopenharmony_ci| Map           | 5 | Geographical address.                   |
7066e41f4b71Sopenharmony_ci| Phone         | 6 | Phone number.                   |
7067e41f4b71Sopenharmony_ci| Unknown       | 7 | Unknown content.                   |
7068e41f4b71Sopenharmony_ci
7069e41f4b71Sopenharmony_ci ## OverScrollMode<sup>11+</sup>
7070e41f4b71Sopenharmony_ci
7071e41f4b71Sopenharmony_ci| Name    | Value| Description         |
7072e41f4b71Sopenharmony_ci| ------ | -- | ----------- |
7073e41f4b71Sopenharmony_ci| NEVER  | 0 | The overscroll mode is disabled.|
7074e41f4b71Sopenharmony_ci| ALWAYS | 1 | The overscroll mode is enabled.|
7075e41f4b71Sopenharmony_ci
7076e41f4b71Sopenharmony_ci## OnContextMenuHideCallback<sup>11+</sup>
7077e41f4b71Sopenharmony_ci
7078e41f4b71Sopenharmony_ciImplements the callback context menu customizes the hidden callback.
7079e41f4b71Sopenharmony_ci
7080e41f4b71Sopenharmony_ci## SslError<sup>9+</sup>
7081e41f4b71Sopenharmony_ci
7082e41f4b71Sopenharmony_ciEnumerates the error codes returned by **onSslErrorEventReceive** API.
7083e41f4b71Sopenharmony_ci
7084e41f4b71Sopenharmony_ci| Name          | Value| Description         |
7085e41f4b71Sopenharmony_ci| ------------ | -- | ----------- |
7086e41f4b71Sopenharmony_ci| Invalid      | 0 | Minor error.      |
7087e41f4b71Sopenharmony_ci| HostMismatch | 1 | The host name does not match.    |
7088e41f4b71Sopenharmony_ci| DateInvalid  | 2 | The certificate has an invalid date.    |
7089e41f4b71Sopenharmony_ci| Untrusted    | 3 | The certificate issuer is not trusted.|
7090e41f4b71Sopenharmony_ci
7091e41f4b71Sopenharmony_ci## ProtectedResourceType<sup>9+</sup>
7092e41f4b71Sopenharmony_ci
7093e41f4b71Sopenharmony_ci| Name                         | Value| Description           | Remarks                        |
7094e41f4b71Sopenharmony_ci| --------------------------- | --------------- | ------------- | -------------------------- |
7095e41f4b71Sopenharmony_ci| MidiSysex                   | TYPE_MIDI_SYSEX | MIDI SYSEX resource.| Currently, only permission events can be reported. MIDI devices are not yet supported.|
7096e41f4b71Sopenharmony_ci| VIDEO_CAPTURE<sup>10+</sup> | TYPE_VIDEO_CAPTURE | Video capture resource, such as a camera. |                            |
7097e41f4b71Sopenharmony_ci| AUDIO_CAPTURE<sup>10+</sup> | TYPE_AUDIO_CAPTURE | Audio capture resource, such as a microphone.|                            |
7098e41f4b71Sopenharmony_ci| SENSOR<sup>12+</sup>        | TYPE_SENSOR | Sensor resource, such as an acceleration sensor.|                            |
7099e41f4b71Sopenharmony_ci
7100e41f4b71Sopenharmony_ci## WebDarkMode<sup>9+</sup>
7101e41f4b71Sopenharmony_ci
7102e41f4b71Sopenharmony_ci| Name  | Value| Description          |
7103e41f4b71Sopenharmony_ci| ---- | -- | ------------ |
7104e41f4b71Sopenharmony_ci| Off  | 0 | The web dark mode is disabled.  |
7105e41f4b71Sopenharmony_ci| On   | 1 | The web dark mode is enabled.  |
7106e41f4b71Sopenharmony_ci| Auto | 2 | The web dark mode setting follows the system settings.|
7107e41f4b71Sopenharmony_ci
7108e41f4b71Sopenharmony_ci## WebCaptureMode<sup>10+</sup>
7109e41f4b71Sopenharmony_ci
7110e41f4b71Sopenharmony_ci| Name         | Value| Description     |
7111e41f4b71Sopenharmony_ci| ----------- | -- | ------- |
7112e41f4b71Sopenharmony_ci| HOME_SCREEN | 0 | Capture of the home screen.|
7113e41f4b71Sopenharmony_ci
7114e41f4b71Sopenharmony_ci## WebMediaOptions<sup>10+</sup>
7115e41f4b71Sopenharmony_ci
7116e41f4b71Sopenharmony_ciDescribes the web-based media playback policy.
7117e41f4b71Sopenharmony_ci
7118e41f4b71Sopenharmony_ci| Name            | Type     | Readable  | Writable  | Mandatory  | Description                                      |
7119e41f4b71Sopenharmony_ci| -------------- | ------- | ---- | ---- | ---- | ---------------------------------------- |
7120e41f4b71Sopenharmony_ci| resumeInterval | number  | Yes   | Yes   | No   | Validity period for automatically resuming a paused web audio, in seconds. The maximum validity period is 60 seconds. Due to the approximate value, the validity period may have a deviation of less than 1 second.|
7121e41f4b71Sopenharmony_ci| audioExclusive | boolean | Yes   | Yes   | No   | Whether the audio of multiple **Web** instances in an application is exclusive.                      |
7122e41f4b71Sopenharmony_ci
7123e41f4b71Sopenharmony_ci## ScreenCaptureConfig<sup>10+</sup>
7124e41f4b71Sopenharmony_ci
7125e41f4b71Sopenharmony_ciProvides the web screen capture configuration.
7126e41f4b71Sopenharmony_ci
7127e41f4b71Sopenharmony_ci| Name         | Type                                     | Readable  | Writable  | Mandatory  | Description        |
7128e41f4b71Sopenharmony_ci| ----------- | --------------------------------------- | ---- | ---- | ---- | ---------- |
7129e41f4b71Sopenharmony_ci| captureMode | [WebCaptureMode](#webcapturemode10) | Yes   | Yes   | Yes   | Web screen capture mode.|
7130e41f4b71Sopenharmony_ci
7131e41f4b71Sopenharmony_ci## WebLayoutMode<sup>11+</sup>
7132e41f4b71Sopenharmony_ci
7133e41f4b71Sopenharmony_ci| Name         | Value| Description                |
7134e41f4b71Sopenharmony_ci| ----------- | -- | ------------------ |
7135e41f4b71Sopenharmony_ci| NONE        | 0 | The web layout follows the system.        |
7136e41f4b71Sopenharmony_ci| FIT_CONTENT | 1 | The web layout adapts to the page size.|
7137e41f4b71Sopenharmony_ci
7138e41f4b71Sopenharmony_ci## NestedScrollOptions<sup>11+</sup>
7139e41f4b71Sopenharmony_ci
7140e41f4b71Sopenharmony_ci| Name            | Type              | Description                  |
7141e41f4b71Sopenharmony_ci| -------------- | ---------------- | -------------------- |
7142e41f4b71Sopenharmony_ci| scrollForward  | [NestedScrollMode](#nestedscrollmode11) | Nested scrolling options when the component scrolls forward.|
7143e41f4b71Sopenharmony_ci| scrollBackward | [NestedScrollMode](#nestedscrollmode11) | Nested scrolling options when the component scrolls backward.|
7144e41f4b71Sopenharmony_ci
7145e41f4b71Sopenharmony_ci## NestedScrollMode<sup>11+</sup>
7146e41f4b71Sopenharmony_ci
7147e41f4b71Sopenharmony_ci| Name          | Value| Description                                      |
7148e41f4b71Sopenharmony_ci| ------------ | -- | ---------------------------------------- |
7149e41f4b71Sopenharmony_ci| SELF_ONLY    | 0 | The scrolling is contained within the component, and no scroll chaining occurs, that is, the parent component does not scroll when the component scrolling reaches the boundary.                          |
7150e41f4b71Sopenharmony_ci| SELF_FIRST   | 1 | The component scrolls first, and when it hits the boundary, the parent component scrolls. When the parent component hits the boundary, its edge effect is displayed. If no edge effect is specified for the parent component, the edge effect of the child component is displayed instead.|
7151e41f4b71Sopenharmony_ci| PARENT_FIRST | 2 | The parent component scrolls first, and when it hits the boundary, the component scrolls. When the component hits the boundary, its edge effect is displayed. If no edge effect is specified for the component, the edge effect of the parent component is displayed instead.|
7152e41f4b71Sopenharmony_ci| PARALLEL     | 3 | The component and its parent component scroll at the same time. When both the component and its parent component hit the boundary, the edge effect of the component is displayed. If no edge effect is specified for the component, the edge effect of the parent component is displayed instead.|
7153e41f4b71Sopenharmony_ci
7154e41f4b71Sopenharmony_ci## DataResubmissionHandler<sup>9+</sup>
7155e41f4b71Sopenharmony_ci
7156e41f4b71Sopenharmony_ciImplements the **DataResubmissionHandler** object for resubmitting or canceling the web form data.
7157e41f4b71Sopenharmony_ci
7158e41f4b71Sopenharmony_ci### resend<sup>9+</sup>
7159e41f4b71Sopenharmony_ci
7160e41f4b71Sopenharmony_ciresend(): void
7161e41f4b71Sopenharmony_ci
7162e41f4b71Sopenharmony_ciResends the web form data.
7163e41f4b71Sopenharmony_ci
7164e41f4b71Sopenharmony_ci**Example**
7165e41f4b71Sopenharmony_ci
7166e41f4b71Sopenharmony_ci  ```ts
7167e41f4b71Sopenharmony_ci  // xxx.ets
7168e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
7169e41f4b71Sopenharmony_ci
7170e41f4b71Sopenharmony_ci  @Entry
7171e41f4b71Sopenharmony_ci  @Component
7172e41f4b71Sopenharmony_ci  struct WebComponent {
7173e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
7174e41f4b71Sopenharmony_ci
7175e41f4b71Sopenharmony_ci    build() {
7176e41f4b71Sopenharmony_ci      Column() {
7177e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7178e41f4b71Sopenharmony_ci          .onDataResubmitted((event) => {
7179e41f4b71Sopenharmony_ci            console.log('onDataResubmitted');
7180e41f4b71Sopenharmony_ci            event.handler.resend();
7181e41f4b71Sopenharmony_ci          })
7182e41f4b71Sopenharmony_ci      }
7183e41f4b71Sopenharmony_ci    }
7184e41f4b71Sopenharmony_ci  }
7185e41f4b71Sopenharmony_ci  ```
7186e41f4b71Sopenharmony_ci
7187e41f4b71Sopenharmony_ci### cancel<sup>9+</sup>
7188e41f4b71Sopenharmony_ci
7189e41f4b71Sopenharmony_cicancel(): void
7190e41f4b71Sopenharmony_ci
7191e41f4b71Sopenharmony_ciCancels the resending of web form data.
7192e41f4b71Sopenharmony_ci
7193e41f4b71Sopenharmony_ci**Example**
7194e41f4b71Sopenharmony_ci
7195e41f4b71Sopenharmony_ci  ```ts
7196e41f4b71Sopenharmony_ci  // xxx.ets
7197e41f4b71Sopenharmony_ci  import { webview } from '@kit.ArkWeb';
7198e41f4b71Sopenharmony_ci
7199e41f4b71Sopenharmony_ci  @Entry
7200e41f4b71Sopenharmony_ci  @Component
7201e41f4b71Sopenharmony_ci  struct WebComponent {
7202e41f4b71Sopenharmony_ci    controller: webview.WebviewController = new webview.WebviewController();
7203e41f4b71Sopenharmony_ci
7204e41f4b71Sopenharmony_ci    build() {
7205e41f4b71Sopenharmony_ci      Column() {
7206e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7207e41f4b71Sopenharmony_ci          .onDataResubmitted((event) => {
7208e41f4b71Sopenharmony_ci            console.log('onDataResubmitted');
7209e41f4b71Sopenharmony_ci            event.handler.cancel();
7210e41f4b71Sopenharmony_ci          })
7211e41f4b71Sopenharmony_ci      }
7212e41f4b71Sopenharmony_ci    }
7213e41f4b71Sopenharmony_ci  }
7214e41f4b71Sopenharmony_ci  ```
7215e41f4b71Sopenharmony_ci
7216e41f4b71Sopenharmony_ci  ## WebController
7217e41f4b71Sopenharmony_ci
7218e41f4b71Sopenharmony_ciImplements a **WebController** to control the behavior of the **Web** component. A **WebController** can control only one **Web** component, and the APIs in the **WebController** can be invoked only after it has been bound to the target **Web** component.
7219e41f4b71Sopenharmony_ci
7220e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [WebviewController<sup>9+</sup>](js-apis-webview.md#webviewcontroller) instead.
7221e41f4b71Sopenharmony_ci
7222e41f4b71Sopenharmony_ci### Creating an Object
7223e41f4b71Sopenharmony_ci
7224e41f4b71Sopenharmony_ci```ts
7225e41f4b71Sopenharmony_cilet webController: WebController = new WebController()
7226e41f4b71Sopenharmony_ci```
7227e41f4b71Sopenharmony_ci
7228e41f4b71Sopenharmony_ci### getCookieManager<sup>(deprecated)</sup>
7229e41f4b71Sopenharmony_ci
7230e41f4b71Sopenharmony_cigetCookieManager(): WebCookie
7231e41f4b71Sopenharmony_ci
7232e41f4b71Sopenharmony_ciObtains the cookie management object of the **Web** component.
7233e41f4b71Sopenharmony_ci
7234e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [getCookie](js-apis-webview.md#getcookiedeprecated) instead.
7235e41f4b71Sopenharmony_ci
7236e41f4b71Sopenharmony_ci**Return value**
7237e41f4b71Sopenharmony_ci
7238e41f4b71Sopenharmony_ci| Type       | Description                                      |
7239e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- |
7240e41f4b71Sopenharmony_ci| WebCookie | Cookie management object. For details, see [WebCookie](#webcookiedeprecated).|
7241e41f4b71Sopenharmony_ci
7242e41f4b71Sopenharmony_ci**Example**
7243e41f4b71Sopenharmony_ci
7244e41f4b71Sopenharmony_ci  ```ts
7245e41f4b71Sopenharmony_ci  // xxx.ets
7246e41f4b71Sopenharmony_ci  @Entry
7247e41f4b71Sopenharmony_ci  @Component
7248e41f4b71Sopenharmony_ci  struct WebComponent {
7249e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7250e41f4b71Sopenharmony_ci
7251e41f4b71Sopenharmony_ci    build() {
7252e41f4b71Sopenharmony_ci      Column() {
7253e41f4b71Sopenharmony_ci        Button('getCookieManager')
7254e41f4b71Sopenharmony_ci          .onClick(() => {
7255e41f4b71Sopenharmony_ci            let cookieManager = this.controller.getCookieManager()
7256e41f4b71Sopenharmony_ci          })
7257e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7258e41f4b71Sopenharmony_ci      }
7259e41f4b71Sopenharmony_ci    }
7260e41f4b71Sopenharmony_ci  }
7261e41f4b71Sopenharmony_ci  ```
7262e41f4b71Sopenharmony_ci
7263e41f4b71Sopenharmony_ci### requestFocus<sup>(deprecated)</sup>
7264e41f4b71Sopenharmony_ci
7265e41f4b71Sopenharmony_cirequestFocus()
7266e41f4b71Sopenharmony_ci
7267e41f4b71Sopenharmony_ciRequests focus for this web page.
7268e41f4b71Sopenharmony_ci
7269e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [requestFocus<sup>9+</sup>](js-apis-webview.md#requestfocus) instead.
7270e41f4b71Sopenharmony_ci
7271e41f4b71Sopenharmony_ci**Example**
7272e41f4b71Sopenharmony_ci
7273e41f4b71Sopenharmony_ci  ```ts
7274e41f4b71Sopenharmony_ci  // xxx.ets
7275e41f4b71Sopenharmony_ci  @Entry
7276e41f4b71Sopenharmony_ci  @Component
7277e41f4b71Sopenharmony_ci  struct WebComponent {
7278e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7279e41f4b71Sopenharmony_ci
7280e41f4b71Sopenharmony_ci    build() {
7281e41f4b71Sopenharmony_ci      Column() {
7282e41f4b71Sopenharmony_ci        Button('requestFocus')
7283e41f4b71Sopenharmony_ci          .onClick(() => {
7284e41f4b71Sopenharmony_ci            this.controller.requestFocus()
7285e41f4b71Sopenharmony_ci          })
7286e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7287e41f4b71Sopenharmony_ci      }
7288e41f4b71Sopenharmony_ci    }
7289e41f4b71Sopenharmony_ci  }
7290e41f4b71Sopenharmony_ci  ```
7291e41f4b71Sopenharmony_ci
7292e41f4b71Sopenharmony_ci### accessBackward<sup>(deprecated)</sup>
7293e41f4b71Sopenharmony_ci
7294e41f4b71Sopenharmony_ciaccessBackward(): boolean
7295e41f4b71Sopenharmony_ci
7296e41f4b71Sopenharmony_ciChecks whether going to the previous page can be performed on the current page.
7297e41f4b71Sopenharmony_ci
7298e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [accessBackward<sup>9+</sup>](js-apis-webview.md#accessbackward) instead.
7299e41f4b71Sopenharmony_ci
7300e41f4b71Sopenharmony_ci**Return value**
7301e41f4b71Sopenharmony_ci
7302e41f4b71Sopenharmony_ci| Type     | Description                   |
7303e41f4b71Sopenharmony_ci| ------- | --------------------- |
7304e41f4b71Sopenharmony_ci| boolean | Returns **true** if going to the previous page can be performed on the current page; returns **false** otherwise.|
7305e41f4b71Sopenharmony_ci
7306e41f4b71Sopenharmony_ci**Example**
7307e41f4b71Sopenharmony_ci
7308e41f4b71Sopenharmony_ci  ```ts
7309e41f4b71Sopenharmony_ci  // xxx.ets
7310e41f4b71Sopenharmony_ci  @Entry
7311e41f4b71Sopenharmony_ci  @Component
7312e41f4b71Sopenharmony_ci  struct WebComponent {
7313e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7314e41f4b71Sopenharmony_ci
7315e41f4b71Sopenharmony_ci    build() {
7316e41f4b71Sopenharmony_ci      Column() {
7317e41f4b71Sopenharmony_ci        Button('accessBackward')
7318e41f4b71Sopenharmony_ci          .onClick(() => {
7319e41f4b71Sopenharmony_ci            let result = this.controller.accessBackward()
7320e41f4b71Sopenharmony_ci            console.log('result:' + result)
7321e41f4b71Sopenharmony_ci          })
7322e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7323e41f4b71Sopenharmony_ci      }
7324e41f4b71Sopenharmony_ci    }
7325e41f4b71Sopenharmony_ci  }
7326e41f4b71Sopenharmony_ci  ```
7327e41f4b71Sopenharmony_ci
7328e41f4b71Sopenharmony_ci### accessForward<sup>(deprecated)</sup>
7329e41f4b71Sopenharmony_ci
7330e41f4b71Sopenharmony_ciaccessForward(): boolean
7331e41f4b71Sopenharmony_ci
7332e41f4b71Sopenharmony_ciChecks whether going to the next page can be performed on the current page.
7333e41f4b71Sopenharmony_ci
7334e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [accessForward<sup>9+</sup>](js-apis-webview.md#accessforward) instead.
7335e41f4b71Sopenharmony_ci
7336e41f4b71Sopenharmony_ci**Return value**
7337e41f4b71Sopenharmony_ci
7338e41f4b71Sopenharmony_ci| Type     | Description                   |
7339e41f4b71Sopenharmony_ci| ------- | --------------------- |
7340e41f4b71Sopenharmony_ci| boolean | Returns **true** if going to the next page can be performed on the current page; returns **false** otherwise.|
7341e41f4b71Sopenharmony_ci
7342e41f4b71Sopenharmony_ci**Example**
7343e41f4b71Sopenharmony_ci
7344e41f4b71Sopenharmony_ci  ```ts
7345e41f4b71Sopenharmony_ci  // xxx.ets
7346e41f4b71Sopenharmony_ci  @Entry
7347e41f4b71Sopenharmony_ci  @Component
7348e41f4b71Sopenharmony_ci  struct WebComponent {
7349e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7350e41f4b71Sopenharmony_ci
7351e41f4b71Sopenharmony_ci    build() {
7352e41f4b71Sopenharmony_ci      Column() {
7353e41f4b71Sopenharmony_ci        Button('accessForward')
7354e41f4b71Sopenharmony_ci          .onClick(() => {
7355e41f4b71Sopenharmony_ci            let result = this.controller.accessForward()
7356e41f4b71Sopenharmony_ci            console.log('result:' + result)
7357e41f4b71Sopenharmony_ci          })
7358e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7359e41f4b71Sopenharmony_ci      }
7360e41f4b71Sopenharmony_ci    }
7361e41f4b71Sopenharmony_ci  }
7362e41f4b71Sopenharmony_ci  ```
7363e41f4b71Sopenharmony_ci
7364e41f4b71Sopenharmony_ci### accessStep<sup>(deprecated)</sup>
7365e41f4b71Sopenharmony_ci
7366e41f4b71Sopenharmony_ciaccessStep(step: number): boolean
7367e41f4b71Sopenharmony_ci
7368e41f4b71Sopenharmony_ciPerforms a specific number of steps forward or backward from the current page.
7369e41f4b71Sopenharmony_ci
7370e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [accessStep<sup>9+</sup>](js-apis-webview.md#accessstep) instead.
7371e41f4b71Sopenharmony_ci
7372e41f4b71Sopenharmony_ci**Parameters**
7373e41f4b71Sopenharmony_ci
7374e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description                 |
7375e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | --------------------- |
7376e41f4b71Sopenharmony_ci| step | number | Yes   | -    | Number of the steps to take. A positive number means to go forward, and a negative number means to go backward.|
7377e41f4b71Sopenharmony_ci
7378e41f4b71Sopenharmony_ci**Return value**
7379e41f4b71Sopenharmony_ci
7380e41f4b71Sopenharmony_ci| Type     | Description       |
7381e41f4b71Sopenharmony_ci| ------- | --------- |
7382e41f4b71Sopenharmony_ci| boolean | Whether going forward or backward from the current page is successful.|
7383e41f4b71Sopenharmony_ci
7384e41f4b71Sopenharmony_ci**Example**
7385e41f4b71Sopenharmony_ci
7386e41f4b71Sopenharmony_ci  ```ts
7387e41f4b71Sopenharmony_ci  // xxx.ets
7388e41f4b71Sopenharmony_ci  @Entry
7389e41f4b71Sopenharmony_ci  @Component
7390e41f4b71Sopenharmony_ci  struct WebComponent {
7391e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7392e41f4b71Sopenharmony_ci    @State steps: number = 2
7393e41f4b71Sopenharmony_ci
7394e41f4b71Sopenharmony_ci    build() {
7395e41f4b71Sopenharmony_ci      Column() {
7396e41f4b71Sopenharmony_ci        Button('accessStep')
7397e41f4b71Sopenharmony_ci          .onClick(() => {
7398e41f4b71Sopenharmony_ci            let result = this.controller.accessStep(this.steps)
7399e41f4b71Sopenharmony_ci            console.log('result:' + result)
7400e41f4b71Sopenharmony_ci          })
7401e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7402e41f4b71Sopenharmony_ci      }
7403e41f4b71Sopenharmony_ci    }
7404e41f4b71Sopenharmony_ci  }
7405e41f4b71Sopenharmony_ci  ```
7406e41f4b71Sopenharmony_ci
7407e41f4b71Sopenharmony_ci### backward<sup>(deprecated)</sup>
7408e41f4b71Sopenharmony_ci
7409e41f4b71Sopenharmony_cibackward(): void
7410e41f4b71Sopenharmony_ci
7411e41f4b71Sopenharmony_ciGoes to the previous page based on the history stack. This API is generally used together with **accessBackward**.
7412e41f4b71Sopenharmony_ci
7413e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [backward<sup>9+</sup>](js-apis-webview.md#backward) instead.
7414e41f4b71Sopenharmony_ci
7415e41f4b71Sopenharmony_ci**Example**
7416e41f4b71Sopenharmony_ci
7417e41f4b71Sopenharmony_ci  ```ts
7418e41f4b71Sopenharmony_ci  // xxx.ets
7419e41f4b71Sopenharmony_ci  @Entry
7420e41f4b71Sopenharmony_ci  @Component
7421e41f4b71Sopenharmony_ci  struct WebComponent {
7422e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7423e41f4b71Sopenharmony_ci
7424e41f4b71Sopenharmony_ci    build() {
7425e41f4b71Sopenharmony_ci      Column() {
7426e41f4b71Sopenharmony_ci        Button('backward')
7427e41f4b71Sopenharmony_ci          .onClick(() => {
7428e41f4b71Sopenharmony_ci            this.controller.backward()
7429e41f4b71Sopenharmony_ci          })
7430e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7431e41f4b71Sopenharmony_ci      }
7432e41f4b71Sopenharmony_ci    }
7433e41f4b71Sopenharmony_ci  }
7434e41f4b71Sopenharmony_ci  ```
7435e41f4b71Sopenharmony_ci
7436e41f4b71Sopenharmony_ci### forward<sup>(deprecated)</sup>
7437e41f4b71Sopenharmony_ci
7438e41f4b71Sopenharmony_ciforward(): void
7439e41f4b71Sopenharmony_ci
7440e41f4b71Sopenharmony_ciGoes to the next page based on the history stack. This API is generally used together with **accessForward**.
7441e41f4b71Sopenharmony_ci
7442e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [forward<sup>9+</sup>](js-apis-webview.md#forward) instead.
7443e41f4b71Sopenharmony_ci
7444e41f4b71Sopenharmony_ci**Example**
7445e41f4b71Sopenharmony_ci
7446e41f4b71Sopenharmony_ci  ```ts
7447e41f4b71Sopenharmony_ci  // xxx.ets
7448e41f4b71Sopenharmony_ci  @Entry
7449e41f4b71Sopenharmony_ci  @Component
7450e41f4b71Sopenharmony_ci  struct WebComponent {
7451e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7452e41f4b71Sopenharmony_ci
7453e41f4b71Sopenharmony_ci    build() {
7454e41f4b71Sopenharmony_ci      Column() {
7455e41f4b71Sopenharmony_ci        Button('forward')
7456e41f4b71Sopenharmony_ci          .onClick(() => {
7457e41f4b71Sopenharmony_ci            this.controller.forward()
7458e41f4b71Sopenharmony_ci          })
7459e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7460e41f4b71Sopenharmony_ci      }
7461e41f4b71Sopenharmony_ci    }
7462e41f4b71Sopenharmony_ci  }
7463e41f4b71Sopenharmony_ci  ```
7464e41f4b71Sopenharmony_ci
7465e41f4b71Sopenharmony_ci### deleteJavaScriptRegister<sup>(deprecated)</sup>
7466e41f4b71Sopenharmony_ci
7467e41f4b71Sopenharmony_cideleteJavaScriptRegister(name: string)
7468e41f4b71Sopenharmony_ci
7469e41f4b71Sopenharmony_ciDeletes a specific application JavaScript object that is registered with the window through **registerJavaScriptProxy**. The deletion takes effect immediately, with no need for invoking the [refresh](#refreshdeprecated) API.
7470e41f4b71Sopenharmony_ci
7471e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [deleteJavaScriptRegister<sup>9+</sup>](js-apis-webview.md#deletejavascriptregister) instead.
7472e41f4b71Sopenharmony_ci
7473e41f4b71Sopenharmony_ci**Parameters**
7474e41f4b71Sopenharmony_ci
7475e41f4b71Sopenharmony_ci| Name | Type  | Mandatory  | Default Value | Description                                    |
7476e41f4b71Sopenharmony_ci| ---- | ------ | ---- | ---- | ---------------------------------------- |
7477e41f4b71Sopenharmony_ci| name | string | Yes   | -    | Name of the registered JavaScript object, which can be used to invoke the corresponding object on the application side from the web side.|
7478e41f4b71Sopenharmony_ci
7479e41f4b71Sopenharmony_ci**Example**
7480e41f4b71Sopenharmony_ci
7481e41f4b71Sopenharmony_ci  ```ts
7482e41f4b71Sopenharmony_ci  // xxx.ets
7483e41f4b71Sopenharmony_ci  @Entry
7484e41f4b71Sopenharmony_ci  @Component
7485e41f4b71Sopenharmony_ci  struct WebComponent {
7486e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7487e41f4b71Sopenharmony_ci    @State name: string = 'Object'
7488e41f4b71Sopenharmony_ci
7489e41f4b71Sopenharmony_ci    build() {
7490e41f4b71Sopenharmony_ci      Column() {
7491e41f4b71Sopenharmony_ci        Button('deleteJavaScriptRegister')
7492e41f4b71Sopenharmony_ci          .onClick(() => {
7493e41f4b71Sopenharmony_ci            this.controller.deleteJavaScriptRegister(this.name)
7494e41f4b71Sopenharmony_ci          })
7495e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7496e41f4b71Sopenharmony_ci      }
7497e41f4b71Sopenharmony_ci    }
7498e41f4b71Sopenharmony_ci  }
7499e41f4b71Sopenharmony_ci  ```
7500e41f4b71Sopenharmony_ci
7501e41f4b71Sopenharmony_ci### getHitTest<sup>(deprecated)</sup>
7502e41f4b71Sopenharmony_ci
7503e41f4b71Sopenharmony_cigetHitTest(): HitTestType
7504e41f4b71Sopenharmony_ci
7505e41f4b71Sopenharmony_ciObtains the element type of the area being clicked.
7506e41f4b71Sopenharmony_ci
7507e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [getHitTest<sup>9+</sup>](js-apis-webview.md#gethittest) instead.
7508e41f4b71Sopenharmony_ci
7509e41f4b71Sopenharmony_ci**Return value**
7510e41f4b71Sopenharmony_ci
7511e41f4b71Sopenharmony_ci| Type                             | Description         |
7512e41f4b71Sopenharmony_ci| ------------------------------- | ----------- |
7513e41f4b71Sopenharmony_ci| [HitTestType](#hittesttype)| Element type of the area being clicked.|
7514e41f4b71Sopenharmony_ci
7515e41f4b71Sopenharmony_ci**Example**
7516e41f4b71Sopenharmony_ci
7517e41f4b71Sopenharmony_ci  ```ts
7518e41f4b71Sopenharmony_ci  // xxx.ets
7519e41f4b71Sopenharmony_ci  @Entry
7520e41f4b71Sopenharmony_ci  @Component
7521e41f4b71Sopenharmony_ci  struct WebComponent {
7522e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7523e41f4b71Sopenharmony_ci
7524e41f4b71Sopenharmony_ci    build() {
7525e41f4b71Sopenharmony_ci      Column() {
7526e41f4b71Sopenharmony_ci        Button('getHitTest')
7527e41f4b71Sopenharmony_ci          .onClick(() => {
7528e41f4b71Sopenharmony_ci            let hitType = this.controller.getHitTest()
7529e41f4b71Sopenharmony_ci            console.log("hitType: " + hitType)
7530e41f4b71Sopenharmony_ci          })
7531e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7532e41f4b71Sopenharmony_ci      }
7533e41f4b71Sopenharmony_ci    }
7534e41f4b71Sopenharmony_ci  }
7535e41f4b71Sopenharmony_ci  ```
7536e41f4b71Sopenharmony_ci
7537e41f4b71Sopenharmony_ci### loadData<sup>(deprecated)</sup>
7538e41f4b71Sopenharmony_ci
7539e41f4b71Sopenharmony_ciloadData(options: { data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string })
7540e41f4b71Sopenharmony_ci
7541e41f4b71Sopenharmony_ciLoads data. If **baseUrl** is empty, the specified character string will be loaded using the data protocol.
7542e41f4b71Sopenharmony_ci
7543e41f4b71Sopenharmony_ciIf **baseUrl** is set to a data URL, the encoded string will be loaded by the **Web** component using the data protocol.
7544e41f4b71Sopenharmony_ci
7545e41f4b71Sopenharmony_ciIf **baseUrl** is set to an HTTP or HTTPS URL, the encoded string will be processed by the **Web** component as a non-encoded string in a manner similar to **loadUrl**.
7546e41f4b71Sopenharmony_ci
7547e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [loadData<sup>9+</sup>](js-apis-webview.md#loaddata) instead.
7548e41f4b71Sopenharmony_ci
7549e41f4b71Sopenharmony_ci**Parameters**
7550e41f4b71Sopenharmony_ci
7551e41f4b71Sopenharmony_ci| Name       | Type  | Mandatory  | Default Value | Description                                    |
7552e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---- | ---------------------------------------- |
7553e41f4b71Sopenharmony_ci| data       | string | Yes   | -    | Character string obtained after being Base64 or URL encoded.             |
7554e41f4b71Sopenharmony_ci| mimeType   | string | Yes   | -    | Media type (MIME).                             |
7555e41f4b71Sopenharmony_ci| encoding   | string | Yes   | -    | Encoding type, which can be Base64 or URL.               |
7556e41f4b71Sopenharmony_ci| baseUrl    | string | No   | -    | URL (HTTP/HTTPS/data compliant), which is assigned by the **Web** component to **window.origin**.|
7557e41f4b71Sopenharmony_ci| historyUrl | string | No   | -    | Historical record URL. If this parameter is not empty, it can be managed in historical records to implement page going backward and forward. This parameter is invalid when **baseUrl** is left empty.|
7558e41f4b71Sopenharmony_ci
7559e41f4b71Sopenharmony_ci**Example**
7560e41f4b71Sopenharmony_ci
7561e41f4b71Sopenharmony_ci  ```ts
7562e41f4b71Sopenharmony_ci  // xxx.ets
7563e41f4b71Sopenharmony_ci  @Entry
7564e41f4b71Sopenharmony_ci  @Component
7565e41f4b71Sopenharmony_ci  struct WebComponent {
7566e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7567e41f4b71Sopenharmony_ci
7568e41f4b71Sopenharmony_ci    build() {
7569e41f4b71Sopenharmony_ci      Column() {
7570e41f4b71Sopenharmony_ci        Button('loadData')
7571e41f4b71Sopenharmony_ci          .onClick(() => {
7572e41f4b71Sopenharmony_ci            this.controller.loadData({
7573e41f4b71Sopenharmony_ci              data: "<html><body bgcolor=\"white\">Source:<pre>source</pre></body></html>",
7574e41f4b71Sopenharmony_ci              mimeType: "text/html",
7575e41f4b71Sopenharmony_ci              encoding: "UTF-8"
7576e41f4b71Sopenharmony_ci            })
7577e41f4b71Sopenharmony_ci          })
7578e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7579e41f4b71Sopenharmony_ci      }
7580e41f4b71Sopenharmony_ci    }
7581e41f4b71Sopenharmony_ci  }
7582e41f4b71Sopenharmony_ci  ```
7583e41f4b71Sopenharmony_ci
7584e41f4b71Sopenharmony_ci### loadUrl<sup>(deprecated)</sup>
7585e41f4b71Sopenharmony_ci
7586e41f4b71Sopenharmony_ciloadUrl(options: { url: string | Resource, headers?: Array\<Header\> })
7587e41f4b71Sopenharmony_ci
7588e41f4b71Sopenharmony_ciLoads a URL using the specified HTTP header.
7589e41f4b71Sopenharmony_ci
7590e41f4b71Sopenharmony_ciThe object injected through **loadUrl** is valid only in the current document. It will be invalid on a new page navigated to through **loadUrl**.
7591e41f4b71Sopenharmony_ci
7592e41f4b71Sopenharmony_ciThe object injected through **registerJavaScriptProxy** is still valid on a new page redirected through **loadUrl**.
7593e41f4b71Sopenharmony_ci
7594e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [loadUrl<sup>9+</sup>](js-apis-webview.md#loadurl) instead.
7595e41f4b71Sopenharmony_ci
7596e41f4b71Sopenharmony_ci**Parameters**
7597e41f4b71Sopenharmony_ci
7598e41f4b71Sopenharmony_ci| Name    | Type                      | Mandatory  | Default Value | Description          |
7599e41f4b71Sopenharmony_ci| ------- | -------------------------- | ---- | ---- | -------------- |
7600e41f4b71Sopenharmony_ci| url     | string \| Resource                     | Yes   | -    | URL to load.    |
7601e41f4b71Sopenharmony_ci| headers | Array\<[Header](#header)\> | No   | []   | Additional HTTP request header of the URL.|
7602e41f4b71Sopenharmony_ci
7603e41f4b71Sopenharmony_ci**Example**
7604e41f4b71Sopenharmony_ci
7605e41f4b71Sopenharmony_ci  ```ts
7606e41f4b71Sopenharmony_ci  // xxx.ets
7607e41f4b71Sopenharmony_ci  @Entry
7608e41f4b71Sopenharmony_ci  @Component
7609e41f4b71Sopenharmony_ci  struct WebComponent {
7610e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7611e41f4b71Sopenharmony_ci
7612e41f4b71Sopenharmony_ci    build() {
7613e41f4b71Sopenharmony_ci      Column() {
7614e41f4b71Sopenharmony_ci        Button('loadUrl')
7615e41f4b71Sopenharmony_ci          .onClick(() => {
7616e41f4b71Sopenharmony_ci            this.controller.loadUrl({ url: 'www.example.com' })
7617e41f4b71Sopenharmony_ci          })
7618e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7619e41f4b71Sopenharmony_ci      }
7620e41f4b71Sopenharmony_ci    }
7621e41f4b71Sopenharmony_ci  }
7622e41f4b71Sopenharmony_ci  ```
7623e41f4b71Sopenharmony_ci
7624e41f4b71Sopenharmony_ci### onActive<sup>(deprecated)</sup>
7625e41f4b71Sopenharmony_ci
7626e41f4b71Sopenharmony_cionActive(): void
7627e41f4b71Sopenharmony_ci
7628e41f4b71Sopenharmony_ciCalled when the **Web** component enters the active state.
7629e41f4b71Sopenharmony_ci
7630e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [onActive<sup>9+</sup>](js-apis-webview.md#onactive) instead.
7631e41f4b71Sopenharmony_ci
7632e41f4b71Sopenharmony_ci**Example**
7633e41f4b71Sopenharmony_ci
7634e41f4b71Sopenharmony_ci  ```ts
7635e41f4b71Sopenharmony_ci  // xxx.ets
7636e41f4b71Sopenharmony_ci  @Entry
7637e41f4b71Sopenharmony_ci  @Component
7638e41f4b71Sopenharmony_ci  struct WebComponent {
7639e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7640e41f4b71Sopenharmony_ci
7641e41f4b71Sopenharmony_ci    build() {
7642e41f4b71Sopenharmony_ci      Column() {
7643e41f4b71Sopenharmony_ci        Button('onActive')
7644e41f4b71Sopenharmony_ci          .onClick(() => {
7645e41f4b71Sopenharmony_ci            this.controller.onActive()
7646e41f4b71Sopenharmony_ci          })
7647e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7648e41f4b71Sopenharmony_ci      }
7649e41f4b71Sopenharmony_ci    }
7650e41f4b71Sopenharmony_ci  }
7651e41f4b71Sopenharmony_ci  ```
7652e41f4b71Sopenharmony_ci
7653e41f4b71Sopenharmony_ci### onInactive<sup>(deprecated)</sup>
7654e41f4b71Sopenharmony_ci
7655e41f4b71Sopenharmony_cionInactive(): void
7656e41f4b71Sopenharmony_ci
7657e41f4b71Sopenharmony_ciCalled when the **Web** component enters the inactive state.
7658e41f4b71Sopenharmony_ci
7659e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [onInactive<sup>9+</sup>](js-apis-webview.md#oninactive) instead.
7660e41f4b71Sopenharmony_ci
7661e41f4b71Sopenharmony_ci**Example**
7662e41f4b71Sopenharmony_ci
7663e41f4b71Sopenharmony_ci  ```ts
7664e41f4b71Sopenharmony_ci  // xxx.ets
7665e41f4b71Sopenharmony_ci  @Entry
7666e41f4b71Sopenharmony_ci  @Component
7667e41f4b71Sopenharmony_ci  struct WebComponent {
7668e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7669e41f4b71Sopenharmony_ci
7670e41f4b71Sopenharmony_ci    build() {
7671e41f4b71Sopenharmony_ci      Column() {
7672e41f4b71Sopenharmony_ci        Button('onInactive')
7673e41f4b71Sopenharmony_ci          .onClick(() => {
7674e41f4b71Sopenharmony_ci            this.controller.onInactive()
7675e41f4b71Sopenharmony_ci          })
7676e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7677e41f4b71Sopenharmony_ci      }
7678e41f4b71Sopenharmony_ci    }
7679e41f4b71Sopenharmony_ci  }
7680e41f4b71Sopenharmony_ci  ```
7681e41f4b71Sopenharmony_ci
7682e41f4b71Sopenharmony_ci### zoom<sup>(deprecated)</sup>
7683e41f4b71Sopenharmony_cizoom(factor: number): void
7684e41f4b71Sopenharmony_ci
7685e41f4b71Sopenharmony_ciSets a zoom factor for the current web page.
7686e41f4b71Sopenharmony_ci
7687e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [zoom<sup>9+</sup>](js-apis-webview.md#zoom) instead.
7688e41f4b71Sopenharmony_ci
7689e41f4b71Sopenharmony_ci**Parameters**
7690e41f4b71Sopenharmony_ci
7691e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory  | Description                          |
7692e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------ |
7693e41f4b71Sopenharmony_ci| factor | number | Yes   | Zoom factor to set. A positive value indicates zoom-in, and a negative value indicates zoom-out.|
7694e41f4b71Sopenharmony_ci
7695e41f4b71Sopenharmony_ci**Example**
7696e41f4b71Sopenharmony_ci
7697e41f4b71Sopenharmony_ci  ```ts
7698e41f4b71Sopenharmony_ci  // xxx.ets
7699e41f4b71Sopenharmony_ci  @Entry
7700e41f4b71Sopenharmony_ci  @Component
7701e41f4b71Sopenharmony_ci  struct WebComponent {
7702e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7703e41f4b71Sopenharmony_ci    @State factor: number = 1
7704e41f4b71Sopenharmony_ci
7705e41f4b71Sopenharmony_ci    build() {
7706e41f4b71Sopenharmony_ci      Column() {
7707e41f4b71Sopenharmony_ci        Button('zoom')
7708e41f4b71Sopenharmony_ci          .onClick(() => {
7709e41f4b71Sopenharmony_ci            this.controller.zoom(this.factor)
7710e41f4b71Sopenharmony_ci          })
7711e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7712e41f4b71Sopenharmony_ci      }
7713e41f4b71Sopenharmony_ci    }
7714e41f4b71Sopenharmony_ci  }
7715e41f4b71Sopenharmony_ci  ```
7716e41f4b71Sopenharmony_ci
7717e41f4b71Sopenharmony_ci### refresh<sup>(deprecated)</sup>
7718e41f4b71Sopenharmony_ci
7719e41f4b71Sopenharmony_cirefresh()
7720e41f4b71Sopenharmony_ci
7721e41f4b71Sopenharmony_ciCalled when the **Web** component refreshes the web page.
7722e41f4b71Sopenharmony_ci
7723e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [refresh<sup>9+</sup>](js-apis-webview.md#refresh) instead.
7724e41f4b71Sopenharmony_ci
7725e41f4b71Sopenharmony_ci**Example**
7726e41f4b71Sopenharmony_ci
7727e41f4b71Sopenharmony_ci  ```ts
7728e41f4b71Sopenharmony_ci  // xxx.ets
7729e41f4b71Sopenharmony_ci  @Entry
7730e41f4b71Sopenharmony_ci  @Component
7731e41f4b71Sopenharmony_ci  struct WebComponent {
7732e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7733e41f4b71Sopenharmony_ci
7734e41f4b71Sopenharmony_ci    build() {
7735e41f4b71Sopenharmony_ci      Column() {
7736e41f4b71Sopenharmony_ci        Button('refresh')
7737e41f4b71Sopenharmony_ci          .onClick(() => {
7738e41f4b71Sopenharmony_ci            this.controller.refresh()
7739e41f4b71Sopenharmony_ci          })
7740e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7741e41f4b71Sopenharmony_ci      }
7742e41f4b71Sopenharmony_ci    }
7743e41f4b71Sopenharmony_ci  }
7744e41f4b71Sopenharmony_ci  ```
7745e41f4b71Sopenharmony_ci
7746e41f4b71Sopenharmony_ci### registerJavaScriptProxy<sup>(deprecated)</sup>
7747e41f4b71Sopenharmony_ci
7748e41f4b71Sopenharmony_ciregisterJavaScriptProxy(options: { object: object, name: string, methodList: Array\<string\> })
7749e41f4b71Sopenharmony_ci
7750e41f4b71Sopenharmony_ciRegisters a JavaScript object with the window. APIs of this object can then be invoked in the window. You must invoke the [refresh](#refreshdeprecated) API for the registration to take effect.
7751e41f4b71Sopenharmony_ci
7752e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [registerJavaScriptProxy<sup>9+</sup>](js-apis-webview.md#registerjavascriptproxy) instead.
7753e41f4b71Sopenharmony_ci
7754e41f4b71Sopenharmony_ci**Parameters**
7755e41f4b71Sopenharmony_ci
7756e41f4b71Sopenharmony_ci| Name       | Type           | Mandatory  | Default Value | Description                                    |
7757e41f4b71Sopenharmony_ci| ---------- | --------------- | ---- | ---- | ---------------------------------------- |
7758e41f4b71Sopenharmony_ci| object     | object          | Yes   | -    | Application-side JavaScript object to be registered. Methods and attributes can be declared, but cannot be directly called on HTML5. The parameters and return value can only be of the string, number, or Boolean type.|
7759e41f4b71Sopenharmony_ci| name       | string          | Yes   | -    | Name of the object to be registered, which is the same as that invoked in the window. After registration, the window can use this name to access the JavaScript object at the application side.|
7760e41f4b71Sopenharmony_ci| methodList | Array\<string\> | Yes   | -    | Methods of the JavaScript object to be registered at the application side.                |
7761e41f4b71Sopenharmony_ci
7762e41f4b71Sopenharmony_ci**Example**
7763e41f4b71Sopenharmony_ci
7764e41f4b71Sopenharmony_ci  ```ts
7765e41f4b71Sopenharmony_ci  // xxx.ets
7766e41f4b71Sopenharmony_ci  class TestObj {
7767e41f4b71Sopenharmony_ci    constructor() {
7768e41f4b71Sopenharmony_ci    }
7769e41f4b71Sopenharmony_ci
7770e41f4b71Sopenharmony_ci    test(): string {
7771e41f4b71Sopenharmony_ci      return "ArkUI Web Component"
7772e41f4b71Sopenharmony_ci    }
7773e41f4b71Sopenharmony_ci
7774e41f4b71Sopenharmony_ci    toString(): void {
7775e41f4b71Sopenharmony_ci      console.log('Web Component toString')
7776e41f4b71Sopenharmony_ci    }
7777e41f4b71Sopenharmony_ci  }
7778e41f4b71Sopenharmony_ci
7779e41f4b71Sopenharmony_ci  @Entry
7780e41f4b71Sopenharmony_ci  @Component
7781e41f4b71Sopenharmony_ci  struct Index {
7782e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7783e41f4b71Sopenharmony_ci    testObj = new TestObj();
7784e41f4b71Sopenharmony_ci    build() {
7785e41f4b71Sopenharmony_ci      Column() {
7786e41f4b71Sopenharmony_ci        Row() {
7787e41f4b71Sopenharmony_ci          Button('Register JavaScript To Window').onClick(() => {
7788e41f4b71Sopenharmony_ci            this.controller.registerJavaScriptProxy({
7789e41f4b71Sopenharmony_ci              object: this.testObj,
7790e41f4b71Sopenharmony_ci              name: "objName",
7791e41f4b71Sopenharmony_ci              methodList: ["test", "toString"],
7792e41f4b71Sopenharmony_ci            })
7793e41f4b71Sopenharmony_ci          })
7794e41f4b71Sopenharmony_ci        }
7795e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
7796e41f4b71Sopenharmony_ci          .javaScriptAccess(true)
7797e41f4b71Sopenharmony_ci      }
7798e41f4b71Sopenharmony_ci    }
7799e41f4b71Sopenharmony_ci  }
7800e41f4b71Sopenharmony_ci  ```
7801e41f4b71Sopenharmony_ci
7802e41f4b71Sopenharmony_ci  HTML file to be loaded:
7803e41f4b71Sopenharmony_ci  ```html
7804e41f4b71Sopenharmony_ci  <!-- index.html -->
7805e41f4b71Sopenharmony_ci  <!DOCTYPE html>
7806e41f4b71Sopenharmony_ci  <html>
7807e41f4b71Sopenharmony_ci      <meta charset="utf-8">
7808e41f4b71Sopenharmony_ci      <body>
7809e41f4b71Sopenharmony_ci          Hello world!
7810e41f4b71Sopenharmony_ci      </body>
7811e41f4b71Sopenharmony_ci      <script type="text/javascript">
7812e41f4b71Sopenharmony_ci      function htmlTest() {
7813e41f4b71Sopenharmony_ci          str = objName.test("test function")
7814e41f4b71Sopenharmony_ci          console.log('objName.test result:'+ str)
7815e41f4b71Sopenharmony_ci      }
7816e41f4b71Sopenharmony_ci  </script>
7817e41f4b71Sopenharmony_ci  </html>
7818e41f4b71Sopenharmony_ci
7819e41f4b71Sopenharmony_ci  ```
7820e41f4b71Sopenharmony_ci
7821e41f4b71Sopenharmony_ci### runJavaScript<sup>(deprecated)</sup>
7822e41f4b71Sopenharmony_ci
7823e41f4b71Sopenharmony_cirunJavaScript(options: { script: string, callback?: (result: string) => void })
7824e41f4b71Sopenharmony_ci
7825e41f4b71Sopenharmony_ciExecutes a JavaScript script. This API uses an asynchronous callback to return the script execution result. **runJavaScript** can be invoked only after **loadUrl** is executed. For example, it can be invoked in **onPageEnd**.
7826e41f4b71Sopenharmony_ci
7827e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [runJavaScript<sup>9+</sup>](js-apis-webview.md#runjavascript) instead.
7828e41f4b71Sopenharmony_ci
7829e41f4b71Sopenharmony_ci**Parameters**
7830e41f4b71Sopenharmony_ci
7831e41f4b71Sopenharmony_ci| Name     | Type                    | Mandatory  | Default Value | Description                                    |
7832e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | ---- | ---------------------------------------- |
7833e41f4b71Sopenharmony_ci| script   | string                   | Yes   | -    | JavaScript script.                           |
7834e41f4b71Sopenharmony_ci| callback | (result: string) => void | No   | -    | Callback used to return the result. Returns **null** if the JavaScript script fails to be executed or no value is returned.|
7835e41f4b71Sopenharmony_ci
7836e41f4b71Sopenharmony_ci**Example**
7837e41f4b71Sopenharmony_ci
7838e41f4b71Sopenharmony_ci  ```ts
7839e41f4b71Sopenharmony_ci  // xxx.ets
7840e41f4b71Sopenharmony_ci  @Entry
7841e41f4b71Sopenharmony_ci  @Component
7842e41f4b71Sopenharmony_ci  struct WebComponent {
7843e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7844e41f4b71Sopenharmony_ci    @State webResult: string = ''
7845e41f4b71Sopenharmony_ci    build() {
7846e41f4b71Sopenharmony_ci      Column() {
7847e41f4b71Sopenharmony_ci        Text(this.webResult).fontSize(20)
7848e41f4b71Sopenharmony_ci        Web({ src: $rawfile('index.html'), controller: this.controller })
7849e41f4b71Sopenharmony_ci        .javaScriptAccess(true)
7850e41f4b71Sopenharmony_ci        .onPageEnd((event) => {
7851e41f4b71Sopenharmony_ci          this.controller.runJavaScript({
7852e41f4b71Sopenharmony_ci            script: 'test()',
7853e41f4b71Sopenharmony_ci            callback: (result: string)=> {
7854e41f4b71Sopenharmony_ci              this.webResult = result
7855e41f4b71Sopenharmony_ci              console.info(`The test() return value is: ${result}`)
7856e41f4b71Sopenharmony_ci            }})
7857e41f4b71Sopenharmony_ci          if (event) {
7858e41f4b71Sopenharmony_ci            console.info('url: ', event.url)
7859e41f4b71Sopenharmony_ci          }
7860e41f4b71Sopenharmony_ci        })
7861e41f4b71Sopenharmony_ci      }
7862e41f4b71Sopenharmony_ci    }
7863e41f4b71Sopenharmony_ci  }
7864e41f4b71Sopenharmony_ci  ```
7865e41f4b71Sopenharmony_ci  HTML file to be loaded:
7866e41f4b71Sopenharmony_ci  ```html
7867e41f4b71Sopenharmony_ci  <!-- index.html -->
7868e41f4b71Sopenharmony_ci  <!DOCTYPE html>
7869e41f4b71Sopenharmony_ci  <html>
7870e41f4b71Sopenharmony_ci    <meta charset="utf-8">
7871e41f4b71Sopenharmony_ci    <body>
7872e41f4b71Sopenharmony_ci        Hello world!
7873e41f4b71Sopenharmony_ci    </body>
7874e41f4b71Sopenharmony_ci    <script type="text/javascript">
7875e41f4b71Sopenharmony_ci    function test() {
7876e41f4b71Sopenharmony_ci        console.log('Ark WebComponent')
7877e41f4b71Sopenharmony_ci        return "This value is from index.html"
7878e41f4b71Sopenharmony_ci    }
7879e41f4b71Sopenharmony_ci    </script>
7880e41f4b71Sopenharmony_ci  </html>
7881e41f4b71Sopenharmony_ci  ```
7882e41f4b71Sopenharmony_ci
7883e41f4b71Sopenharmony_ci### stop<sup>(deprecated)</sup>
7884e41f4b71Sopenharmony_ci
7885e41f4b71Sopenharmony_cistop()
7886e41f4b71Sopenharmony_ci
7887e41f4b71Sopenharmony_ciStops page loading.
7888e41f4b71Sopenharmony_ci
7889e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [stop<sup>9+</sup>](js-apis-webview.md#stop) instead.
7890e41f4b71Sopenharmony_ci
7891e41f4b71Sopenharmony_ci**Example**
7892e41f4b71Sopenharmony_ci
7893e41f4b71Sopenharmony_ci  ```ts
7894e41f4b71Sopenharmony_ci  // xxx.ets
7895e41f4b71Sopenharmony_ci  @Entry
7896e41f4b71Sopenharmony_ci  @Component
7897e41f4b71Sopenharmony_ci  struct WebComponent {
7898e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7899e41f4b71Sopenharmony_ci
7900e41f4b71Sopenharmony_ci    build() {
7901e41f4b71Sopenharmony_ci      Column() {
7902e41f4b71Sopenharmony_ci        Button('stop')
7903e41f4b71Sopenharmony_ci          .onClick(() => {
7904e41f4b71Sopenharmony_ci            this.controller.stop()
7905e41f4b71Sopenharmony_ci          })
7906e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7907e41f4b71Sopenharmony_ci      }
7908e41f4b71Sopenharmony_ci    }
7909e41f4b71Sopenharmony_ci  }
7910e41f4b71Sopenharmony_ci  ```
7911e41f4b71Sopenharmony_ci
7912e41f4b71Sopenharmony_ci### clearHistory<sup>(deprecated)</sup>
7913e41f4b71Sopenharmony_ci
7914e41f4b71Sopenharmony_ciclearHistory(): void
7915e41f4b71Sopenharmony_ci
7916e41f4b71Sopenharmony_ciClears the browsing history.
7917e41f4b71Sopenharmony_ci
7918e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [clearHistory<sup>9+</sup>](js-apis-webview.md#clearhistory) instead.
7919e41f4b71Sopenharmony_ci
7920e41f4b71Sopenharmony_ci**Example**
7921e41f4b71Sopenharmony_ci
7922e41f4b71Sopenharmony_ci  ```ts
7923e41f4b71Sopenharmony_ci  // xxx.ets
7924e41f4b71Sopenharmony_ci  @Entry
7925e41f4b71Sopenharmony_ci  @Component
7926e41f4b71Sopenharmony_ci  struct WebComponent {
7927e41f4b71Sopenharmony_ci    controller: WebController = new WebController()
7928e41f4b71Sopenharmony_ci
7929e41f4b71Sopenharmony_ci    build() {
7930e41f4b71Sopenharmony_ci      Column() {
7931e41f4b71Sopenharmony_ci        Button('clearHistory')
7932e41f4b71Sopenharmony_ci          .onClick(() => {
7933e41f4b71Sopenharmony_ci            this.controller.clearHistory()
7934e41f4b71Sopenharmony_ci          })
7935e41f4b71Sopenharmony_ci        Web({ src: 'www.example.com', controller: this.controller })
7936e41f4b71Sopenharmony_ci      }
7937e41f4b71Sopenharmony_ci    }
7938e41f4b71Sopenharmony_ci  }
7939e41f4b71Sopenharmony_ci  ```
7940e41f4b71Sopenharmony_ci
7941e41f4b71Sopenharmony_ci## WebCookie<sup>(deprecated)</sup>
7942e41f4b71Sopenharmony_ci
7943e41f4b71Sopenharmony_ciManages behavior of cookies in **Web** components. All **Web** components in an application share a **WebCookie**. You can use the **getCookieManager** API in **controller** to obtain the **WebCookie** for subsequent cookie management.
7944e41f4b71Sopenharmony_ci
7945e41f4b71Sopenharmony_ci### setCookie<sup>(deprecated)</sup>
7946e41f4b71Sopenharmony_ci
7947e41f4b71Sopenharmony_cisetCookie()
7948e41f4b71Sopenharmony_ci
7949e41f4b71Sopenharmony_ciSets the cookie. This API returns the result synchronously. Returns **true** if the operation is successful; returns **false** otherwise.
7950e41f4b71Sopenharmony_ci
7951e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [setCookie<sup>9+</sup>](js-apis-webview.md#setcookie) instead.
7952e41f4b71Sopenharmony_ci
7953e41f4b71Sopenharmony_ci### saveCookie<sup>(deprecated)</sup>
7954e41f4b71Sopenharmony_ci
7955e41f4b71Sopenharmony_cisaveCookie()
7956e41f4b71Sopenharmony_ci
7957e41f4b71Sopenharmony_ciSaves the cookies in the memory to the drive. This API returns the result synchronously.
7958e41f4b71Sopenharmony_ci
7959e41f4b71Sopenharmony_ciThis API is deprecated since API version 9. You are advised to use [saveCookieAsync<sup>9+</sup>](js-apis-webview.md#savecookieasync) instead.
7960e41f4b71Sopenharmony_ci
7961e41f4b71Sopenharmony_ci## ScriptItem<sup>11+</sup>
7962e41f4b71Sopenharmony_ci
7963e41f4b71Sopenharmony_ciDescribes the **ScriptItem** object injected to the **Web** component through the [javaScriptOnDocumentStart](#javascriptondocumentstart11) attribute.
7964e41f4b71Sopenharmony_ci
7965e41f4b71Sopenharmony_ci| Name         | Type            | Mandatory  | Description                   |
7966e41f4b71Sopenharmony_ci| ----------- | -------------- | ---- | --------------------- |
7967e41f4b71Sopenharmony_ci| script      | string         | Yes   | JavaScript script to be injected and executed.|
7968e41f4b71Sopenharmony_ci| scriptRules | Array\<string> | Yes  | Matching rules for allowed sources.<br>1. To allow URLs from all sources, use the wildcard (\*).<br>2. If exact match is required, specify the exact URL, for example, **https:\//www\\.example.com**.<br>3. For fuzzy match, you can use a wildcard (\*) in the website URL, for example, **https://\*.example.com**. Websites such as "x,*.y.com" and "* foobar.com" are not allowed.  <br>4. If the source is an IP address, follow rule 2.<br>5. For protocols other than HTTP/HTTPS (user-defined protocols), exact match and fuzzy match are not supported, and the protocol must end with a slash (/), for example, **resource://**.<br>6. If one of the preceding rules is not met in the **scriptRules**, the **scriptRules** does not take effect.|
7969e41f4b71Sopenharmony_ci
7970e41f4b71Sopenharmony_ci## WebNavigationType<sup>11+</sup>
7971e41f4b71Sopenharmony_ci
7972e41f4b71Sopenharmony_ciDefines the navigation type.
7973e41f4b71Sopenharmony_ci
7974e41f4b71Sopenharmony_ci| Name                          | Value| Description          |
7975e41f4b71Sopenharmony_ci| ----------------------------- | -- | ------------ |
7976e41f4b71Sopenharmony_ci| UNKNOWN                       | 0 | Unknown type.  |
7977e41f4b71Sopenharmony_ci| MAIN_FRAME_NEW_ENTRY          | 1 | Navigation to a new history entry from the main document.  |
7978e41f4b71Sopenharmony_ci| MAIN_FRAME_EXISTING_ENTRY     | 2 | Navigation to an existing history entry from the main document.|
7979e41f4b71Sopenharmony_ci| NAVIGATION_TYPE_NEW_SUBFRAME  | 4 | User-triggered navigation from a subdocument.|
7980e41f4b71Sopenharmony_ci| NAVIGATION_TYPE_AUTO_SUBFRAME | 5 | Non-user-triggered navigation from a subdocument.|
7981e41f4b71Sopenharmony_ci
7982e41f4b71Sopenharmony_ci## LoadCommittedDetails<sup>11+</sup>
7983e41f4b71Sopenharmony_ci
7984e41f4b71Sopenharmony_ciProvides detailed information about the web page that has been submitted for redirection.
7985e41f4b71Sopenharmony_ci
7986e41f4b71Sopenharmony_ci| Name            | Type                                 | Mandatory  | Description                   |
7987e41f4b71Sopenharmony_ci| -----------     | ------------------------------------ | ---- | --------------------- |
7988e41f4b71Sopenharmony_ci| isMainFrame     | boolean                              | Yes   | Whether the document is the main document.|
7989e41f4b71Sopenharmony_ci| isSameDocument  | boolean                              | Yes   | Whether to navigate without changing the document. Example of navigation in the same document: 1. navigation shown in the example; 2. navigation triggered by **pushState** or **replaceState**; 3. navigation to a history entry on the same page. |
7990e41f4b71Sopenharmony_ci| didReplaceEntry | boolean                              | Yes   | Whether the submitted new entry replaces the existing entry. In certain scenarios for navigation to a subdocument, although the existing entry is not replaced, some attributes are changed. |
7991e41f4b71Sopenharmony_ci| navigationType  | [WebNavigationType](#webnavigationtype11)  | Yes   | Navigation type.      |
7992e41f4b71Sopenharmony_ci| url             | string                               | Yes   | URL of the current navigated-to web page.         |
7993e41f4b71Sopenharmony_ci
7994e41f4b71Sopenharmony_ci## ThreatType<sup>11+</sup>
7995e41f4b71Sopenharmony_ci
7996e41f4b71Sopenharmony_ciEnumerates the website threat types.
7997e41f4b71Sopenharmony_ci
7998e41f4b71Sopenharmony_ci| Name            | Value| Description                  |
7999e41f4b71Sopenharmony_ci| ---------------- | -- | ----------------------|
8000e41f4b71Sopenharmony_ci| THREAT_ILLEGAL  | 0 | Illegal website.             |
8001e41f4b71Sopenharmony_ci| THREAT_FRAUD    | 1 | Fraudulent website.             |
8002e41f4b71Sopenharmony_ci| THREAT_RISK     | 2 | Website that poses security risks.     |
8003e41f4b71Sopenharmony_ci| THREAT_WARNING  | 3 | Website suspected to contain unsafe content.|
8004e41f4b71Sopenharmony_ci
8005e41f4b71Sopenharmony_ci## OnNavigationEntryCommittedCallback<sup>11+</sup>
8006e41f4b71Sopenharmony_ci
8007e41f4b71Sopenharmony_citype OnNavigationEntryCommittedCallback = (loadCommittedDetails: [LoadCommittedDetails](#loadcommitteddetails11)) => void
8008e41f4b71Sopenharmony_ci
8009e41f4b71Sopenharmony_ciCalled when a navigation item is submitted.
8010e41f4b71Sopenharmony_ci
8011e41f4b71Sopenharmony_ci| Name               | Type                                          | Description               |
8012e41f4b71Sopenharmony_ci| -------------------- | ------------------------------------------------ | ------------------- |
8013e41f4b71Sopenharmony_ci| loadCommittedDetails | [LoadCommittedDetails](#loadcommitteddetails11)  | Detailed information about the web page that has been submitted for redirection.|
8014e41f4b71Sopenharmony_ci
8015e41f4b71Sopenharmony_ci## OnSafeBrowsingCheckResultCallback<sup>11+</sup>
8016e41f4b71Sopenharmony_ci
8017e41f4b71Sopenharmony_citype OnSafeBrowsingCheckResultCallback = (threatType: ThreatType) => void
8018e41f4b71Sopenharmony_ci
8019e41f4b71Sopenharmony_ciCalled by a website safe browsing check.
8020e41f4b71Sopenharmony_ci
8021e41f4b71Sopenharmony_ci| Name     | Type                     | Description             |
8022e41f4b71Sopenharmony_ci| ---------- | ---------------------------- | ------------------- |
8023e41f4b71Sopenharmony_ci| threatType | [ThreatType](#threattype11)  | Website threat type. |
8024e41f4b71Sopenharmony_ci
8025e41f4b71Sopenharmony_ci## FullScreenEnterEvent<sup>12+</sup>
8026e41f4b71Sopenharmony_ci
8027e41f4b71Sopenharmony_ciProvides details about the callback event for the **Web** component to enter the full-screen mode.
8028e41f4b71Sopenharmony_ci
8029e41f4b71Sopenharmony_ci| Name            | Type                                 | Mandatory  | Description                   |
8030e41f4b71Sopenharmony_ci| -----------     | ------------------------------------ | ---- | --------------------- |
8031e41f4b71Sopenharmony_ci| handler     | [FullScreenExitHandler](#fullscreenexithandler9) | Yes   | Function handle for exiting full screen mode.|
8032e41f4b71Sopenharmony_ci| videoWidth  | number | No   | Video width, in px. If the element that enters fulls screen mode is a **\<video>** element, the value represents its width; if the element that enters fulls screen mode contains a **\<video>** element, the value represents the width of the first sub-video element; in other cases, the value is **0**.|
8033e41f4b71Sopenharmony_ci| videoHeight  | number | No   | Video height, in px. If the element that enters fulls screen mode is a **\<video>** element, the value represents its height; if the element that enters fulls screen mode contains a **\<video>** element, the value represents the height of the first sub-video element; in other cases, the value is **0**.|
8034e41f4b71Sopenharmony_ci
8035e41f4b71Sopenharmony_ci## OnFullScreenEnterCallback<sup>12+</sup>
8036e41f4b71Sopenharmony_ci
8037e41f4b71Sopenharmony_citype OnFullScreenEnterCallback = (event: FullScreenEnterEvent) => void
8038e41f4b71Sopenharmony_ci
8039e41f4b71Sopenharmony_ciCalled when the **Web** component enters full screen mode.
8040e41f4b71Sopenharmony_ci
8041e41f4b71Sopenharmony_ci| Name     | Type                     | Description             |
8042e41f4b71Sopenharmony_ci| ---------- | ---------------------------- | ------------------- |
8043e41f4b71Sopenharmony_ci| event | [FullScreenEnterEvent](#fullscreenenterevent12)  | Callback event for the **Web** component to enter full screen mode.|
8044e41f4b71Sopenharmony_ci
8045e41f4b71Sopenharmony_ci## SslErrorEvent<sup>12+</sup>
8046e41f4b71Sopenharmony_ci
8047e41f4b71Sopenharmony_ciProvides details about the callback invoked when an SSL error occurs during resource loading.
8048e41f4b71Sopenharmony_ci
8049e41f4b71Sopenharmony_ci| Name    | Type                                | Description          |
8050e41f4b71Sopenharmony_ci| ------- | ------------------------------------ | -------------- |
8051e41f4b71Sopenharmony_ci| handler | [SslErrorHandler](#sslerrorhandler9) | User operation.|
8052e41f4b71Sopenharmony_ci| error   | [SslError](#sslerror9)          | Error code.          |
8053e41f4b71Sopenharmony_ci| url   | string           | URL.          |
8054e41f4b71Sopenharmony_ci| originalUrl   | string          | Original URL of the request.          |
8055e41f4b71Sopenharmony_ci| referrer   | string          | Referrer URL.          |
8056e41f4b71Sopenharmony_ci| isFatalError   | boolean           | Whether the error is a fatal error.          |
8057e41f4b71Sopenharmony_ci| isMainFrame   | boolean          | Whether the request is made for the main frame.          |
8058e41f4b71Sopenharmony_ci
8059e41f4b71Sopenharmony_ci
8060e41f4b71Sopenharmony_ci## OnSslErrorEventCallback<sup>12+</sup>
8061e41f4b71Sopenharmony_ci
8062e41f4b71Sopenharmony_citype OnSslErrorEventCallback = (sslErrorEvent: SslErrorEvent) => void
8063e41f4b71Sopenharmony_ci
8064e41f4b71Sopenharmony_ciProvides details about the callback invoked when an SSL error occurs during resource loading.
8065e41f4b71Sopenharmony_ci
8066e41f4b71Sopenharmony_ci| Name     | Type                     | Description             |
8067e41f4b71Sopenharmony_ci| ---------- | ---------------------------- | ------------------- |
8068e41f4b71Sopenharmony_ci| sslErrorEvent | [SslErrorEvent](#sslerrorevent12)  | Details about the callback invoked when an SSL error occurs during resource loading.|
8069e41f4b71Sopenharmony_ci
8070e41f4b71Sopenharmony_ci## NativeEmbedStatus<sup>11+</sup>
8071e41f4b71Sopenharmony_ci
8072e41f4b71Sopenharmony_ciDefines the lifecycle of the **embed** tag. When the same-layer rendering tag exists on the loaded page, **CREATE** is triggered. When the same-layer rendering tag is moved or is enlarged, **UPDATE **is triggered. When the page exits, **DESTROY** is triggered.
8073e41f4b71Sopenharmony_ci
8074e41f4b71Sopenharmony_ci| Name                          | Value| Description          |
8075e41f4b71Sopenharmony_ci| ----------------------------- | -- | ------------ |
8076e41f4b71Sopenharmony_ci| CREATE                        | 0 | The tag is created.  |
8077e41f4b71Sopenharmony_ci| UPDATE                        | 1 | The tag is updated.  |
8078e41f4b71Sopenharmony_ci| DESTROY                       | 2 | The tag is destroyed.|
8079e41f4b71Sopenharmony_ci| ENTER_BFCACHE<sup>12+</sup>   | 3 | The tag enters the BFCache.  |
8080e41f4b71Sopenharmony_ci| LEAVE_BFCACHE<sup>12+</sup>   | 4 | The tag leaves the BFCache.|
8081e41f4b71Sopenharmony_ci
8082e41f4b71Sopenharmony_ci## NativeEmbedInfo<sup>11+</sup>
8083e41f4b71Sopenharmony_ci
8084e41f4b71Sopenharmony_ciProvides detailed information about the **\<embed>** tag.
8085e41f4b71Sopenharmony_ci
8086e41f4b71Sopenharmony_ci| Name               | Type                                 | Mandatory  | Description                       |
8087e41f4b71Sopenharmony_ci|-------------------| ------------------------------------ | ---- |---------------------------|
8088e41f4b71Sopenharmony_ci| id                | string             | No   | ID of the tag.            |
8089e41f4b71Sopenharmony_ci| type              | string                              | No   | Type of the tag. The value is in lowercase.  |
8090e41f4b71Sopenharmony_ci| src               | string                              | No   | **src** information of the tag.           |
8091e41f4b71Sopenharmony_ci| width             | number  | No   | Width of the tag, in px.         |
8092e41f4b71Sopenharmony_ci| height            | number                              | No   | Height of the tag, in px.         |
8093e41f4b71Sopenharmony_ci| url               | string                              | No   | URL of the tag.           |
8094e41f4b71Sopenharmony_ci| tag<sup>12+</sup> | string              | No   | Name of the tag, which consists of uppercase letters.             |
8095e41f4b71Sopenharmony_ci| params<sup>12+</sup>            | map<string, string> | No   | List of key-value pairs contained in the **object** tag that form a map of the Object type. Use the methods provided by the Object type to operate the map object. |
8096e41f4b71Sopenharmony_ci| position<sup>12+</sup>          | Position            | No   | Position of the same-layer tag relative to the **Web** component in the screen coordinate system, which is different from the standard **Position**. The unit is px.|
8097e41f4b71Sopenharmony_ci
8098e41f4b71Sopenharmony_ci## NativeEmbedDataInfo<sup>11+</sup>
8099e41f4b71Sopenharmony_ci
8100e41f4b71Sopenharmony_ciProvides detailed information about the lifecycle changes of the **\<embed>** tag.
8101e41f4b71Sopenharmony_ci
8102e41f4b71Sopenharmony_ci| Name            | Type                                 | Mandatory  | Description                   |
8103e41f4b71Sopenharmony_ci| -----------     | ------------------------------------ | ---- | --------------------- |
8104e41f4b71Sopenharmony_ci| status     | [NativeEmbedStatus](#nativeembedstatus11)             | No   | Lifecycle status of the tag.|
8105e41f4b71Sopenharmony_ci| surfaceId  | string                              | No   | Surface ID of the native image. |
8106e41f4b71Sopenharmony_ci| embedId | string                              | No   | Unique ID of the tag. |
8107e41f4b71Sopenharmony_ci| info  | [NativeEmbedInfo](#nativeembedinfo11)  | No   | Detailed information about the tag.      |
8108e41f4b71Sopenharmony_ci## NativeEmbedTouchInfo<sup>11+</sup>
8109e41f4b71Sopenharmony_ci
8110e41f4b71Sopenharmony_ciProvides touch information of the **\<embed>** tag.
8111e41f4b71Sopenharmony_ci
8112e41f4b71Sopenharmony_ci| Name            | Type                                 | Mandatory  | Description                   |
8113e41f4b71Sopenharmony_ci| -----------     | ------------------------------------ | ---- | --------------------- |
8114e41f4b71Sopenharmony_ci| embedId     | string   | No   | Unique ID of the tag.|
8115e41f4b71Sopenharmony_ci| touchEvent  | [TouchEvent](../apis-arkui/arkui-ts/ts-universal-events-touch.md#touchevent)  | No   | Touch action information.|
8116e41f4b71Sopenharmony_ci| result<sup>12+</sup>     | [EventResult](#eventresult12)   | No   | Gesture event consumption result.|
8117e41f4b71Sopenharmony_ci
8118e41f4b71Sopenharmony_ci## FirstMeaningfulPaint<sup>12+</sup>
8119e41f4b71Sopenharmony_ci
8120e41f4b71Sopenharmony_ciProvides detailed information about the first meaningful paint.
8121e41f4b71Sopenharmony_ci
8122e41f4b71Sopenharmony_ci| Name                    | Type  | Mandatory| Description                                  |
8123e41f4b71Sopenharmony_ci| ------------------------ | ------ | ---- | -------------------------------------- |
8124e41f4b71Sopenharmony_ci| navigationStartTime      | number | No | Navigation bar loading time, in microseconds.      |
8125e41f4b71Sopenharmony_ci| firstMeaningfulPaintTime | number | No  | Time taken for the first meaningful paint of the page, in milliseconds.|
8126e41f4b71Sopenharmony_ci
8127e41f4b71Sopenharmony_ci## OnFirstMeaningfulPaintCallback<sup>12+</sup>
8128e41f4b71Sopenharmony_ci
8129e41f4b71Sopenharmony_citype OnFirstMeaningfulPaintCallback = (firstMeaningfulPaint: [FirstMeaningfulPaint](#firstmeaningfulpaint12)) => void
8130e41f4b71Sopenharmony_ci
8131e41f4b71Sopenharmony_ciCalled when the first meaningful paint occurs on the web page.
8132e41f4b71Sopenharmony_ci
8133e41f4b71Sopenharmony_ci| Name              | Type                                       | Description                        |
8134e41f4b71Sopenharmony_ci| -------------------- | ----------------------------------------------- | -------------------------------- |
8135e41f4b71Sopenharmony_ci| firstMeaningfulPaint | [FirstMeaningfulPaint](#firstmeaningfulpaint12) | Information about the first meaningful paint.|
8136e41f4b71Sopenharmony_ci
8137e41f4b71Sopenharmony_ci## LargestContentfulPaint<sup>12+</sup>
8138e41f4b71Sopenharmony_ci
8139e41f4b71Sopenharmony_ciProvides detailed information about the largest content paint.
8140e41f4b71Sopenharmony_ci
8141e41f4b71Sopenharmony_ci| Name                     | Type  | Mandatory| Description                                    |
8142e41f4b71Sopenharmony_ci| ------------------------- | ------ | ---- | ---------------------------------------- |
8143e41f4b71Sopenharmony_ci| navigationStartTime       | number | No  | Navigation bar loading time, in microseconds.        |
8144e41f4b71Sopenharmony_ci| largestImagePaintTime     | number | No  | Maximum image loading time, in milliseconds.  |
8145e41f4b71Sopenharmony_ci| largestTextPaintTime      | number | No  | Maximum text loading time, in milliseconds.    |
8146e41f4b71Sopenharmony_ci| largestImageLoadStartTime | number | No  | Maximum time for an image to start loading, in milliseconds.|
8147e41f4b71Sopenharmony_ci| largestImageLoadEndTime   | number | No  | Maximum time for an image to finish loading, in milliseconds.|
8148e41f4b71Sopenharmony_ci| imageBPP                  | number | No  | Maximum number of image pixels.                          |
8149e41f4b71Sopenharmony_ci
8150e41f4b71Sopenharmony_ci## OnLargestContentfulPaintCallback<sup>12+</sup>
8151e41f4b71Sopenharmony_ci
8152e41f4b71Sopenharmony_citype OnLargestContentfulPaintCallback = (largestContentfulPaint: [LargestContentfulPaint](#largestcontentfulpaint12
8153e41f4b71Sopenharmony_ci)) => void
8154e41f4b71Sopenharmony_ci
8155e41f4b71Sopenharmony_ciCalled when the largest content paint occurs on the web page.
8156e41f4b71Sopenharmony_ci
8157e41f4b71Sopenharmony_ci| Name                | Type                                           | Description                            |
8158e41f4b71Sopenharmony_ci| ---------------------- | --------------------------------------------------- | ------------------------------------ |
8159e41f4b71Sopenharmony_ci| largestContentfulPaint | [LargestContentfulPaint](#largestcontentfulpaint12) | Information about the largest content paint.|
8160e41f4b71Sopenharmony_ci
8161e41f4b71Sopenharmony_ci## IntelligentTrackingPreventionDetails<sup>12+</sup>
8162e41f4b71Sopenharmony_ci
8163e41f4b71Sopenharmony_ciProvides detailed information about intelligent tracking prevention.
8164e41f4b71Sopenharmony_ci
8165e41f4b71Sopenharmony_ci| Name          | Type                               | Mandatory  | Description        |
8166e41f4b71Sopenharmony_ci| ------------- | ------------------------------------| ----- | ------------ |
8167e41f4b71Sopenharmony_ci| host          | string                              | Yes    | Domain name.   |
8168e41f4b71Sopenharmony_ci| trackerHost   | string                              | Yes    | Domain name of the tracker. |
8169e41f4b71Sopenharmony_ci
8170e41f4b71Sopenharmony_ci## OnIntelligentTrackingPreventionCallback<sup>12+</sup>
8171e41f4b71Sopenharmony_ci
8172e41f4b71Sopenharmony_citype OnIntelligentTrackingPreventionCallback = (details: IntelligentTrackingPreventionDetails) => void
8173e41f4b71Sopenharmony_ci
8174e41f4b71Sopenharmony_ciRepresents the callback invoked when the tracker cookie is intercepted.
8175e41f4b71Sopenharmony_ci
8176e41f4b71Sopenharmony_ci| Name  | Type                                                                         | Description                   |
8177e41f4b71Sopenharmony_ci| ------- | -------------------------------------------------------------------------------- | ------------------------- |
8178e41f4b71Sopenharmony_ci| details | [IntelligentTrackingPreventionDetails](#intelligenttrackingpreventiondetails12)  | Detailed information about intelligent tracking prevention.|
8179e41f4b71Sopenharmony_ci
8180e41f4b71Sopenharmony_ci## OnOverrideUrlLoadingCallback<sup>12+</sup>
8181e41f4b71Sopenharmony_ci
8182e41f4b71Sopenharmony_citype OnOverrideUrlLoadingCallback = (webResourceRequest: WebResourceRequest) => boolean
8183e41f4b71Sopenharmony_ci
8184e41f4b71Sopenharmony_ciRepresents a callback for **onOverrideUrlLoading**.
8185e41f4b71Sopenharmony_ci
8186e41f4b71Sopenharmony_ci**Parameters**
8187e41f4b71Sopenharmony_ci
8188e41f4b71Sopenharmony_ci| Name               | Type                                          | Description               |
8189e41f4b71Sopenharmony_ci| -------------------- | ------------------------------------------------ | ------------------- |
8190e41f4b71Sopenharmony_ci| webResourceRequest | [WebResourceRequest](#webresourcerequest)  | Information about the URL request.|
8191e41f4b71Sopenharmony_ci
8192e41f4b71Sopenharmony_ci**Return value**
8193e41f4b71Sopenharmony_ci
8194e41f4b71Sopenharmony_ci| Type     | Description                      |
8195e41f4b71Sopenharmony_ci| ------- | ------------------------ |
8196e41f4b71Sopenharmony_ci| boolean | Returns **true** if the access is blocked; returns **false** otherwise.|
8197e41f4b71Sopenharmony_ci
8198e41f4b71Sopenharmony_ci## RenderMode<sup>12+</sup>
8199e41f4b71Sopenharmony_ci
8200e41f4b71Sopenharmony_ciEnumerates the rendering modes of the **Web** component.
8201e41f4b71Sopenharmony_ci
8202e41f4b71Sopenharmony_ci| Name                          | Value| Description          |
8203e41f4b71Sopenharmony_ci| ----------------------------- | -- | ------------ |
8204e41f4b71Sopenharmony_ci| ASYNC_RENDER                        | 0 | The **Web** component is rendered asynchronously.  |
8205e41f4b71Sopenharmony_ci| SYNC_RENDER                        | 1 | The **Web** component is rendered synchronously within the current execution context.  |
8206e41f4b71Sopenharmony_ci
8207e41f4b71Sopenharmony_ci## NativeMediaPlayerConfig<sup>12+</sup>
8208e41f4b71Sopenharmony_ci
8209e41f4b71Sopenharmony_citype NativeMediaPlayerConfig = { enable: boolean, shouldOverlay: boolean }
8210e41f4b71Sopenharmony_ci
8211e41f4b71Sopenharmony_ciRepresents the configuration for [enabling the application to take over web page media playback](#enablenativemediaplayer12).
8212e41f4b71Sopenharmony_ci
8213e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Web.Webview.Core
8214e41f4b71Sopenharmony_ci
8215e41f4b71Sopenharmony_ci| Name| Type| Read Only| Mandatory| Description|
8216e41f4b71Sopenharmony_ci|------|------|------|------|------|
8217e41f4b71Sopenharmony_ci|  enable  | boolean | No| Yes| Whether to enable the feature.<br> **true**: enabled<br> **false** (default): disabled|
8218e41f4b71Sopenharmony_ci|  shouldOverlay | boolean | No| Yes| Whether the video player's display overlays the web page content when the application takes over the web page's video player.<br> **true**: The video player's display overlays the web page content. This means that the height of the video layer is adjusted to cover the web page content.<br> **false** (default): The video player's display does not overlay the web page content. This means that the video player maintains its original height and is embedded within the web page.|
8219e41f4b71Sopenharmony_ci
8220e41f4b71Sopenharmony_ci## RenderProcessNotRespondingReason<sup>12+</sup>
8221e41f4b71Sopenharmony_ci
8222e41f4b71Sopenharmony_ciProvides the reason why the rendering process does not respond.
8223e41f4b71Sopenharmony_ci
8224e41f4b71Sopenharmony_ci| Name                          | Value| Description          |
8225e41f4b71Sopenharmony_ci| ----------------------------- | -- | ------------ |
8226e41f4b71Sopenharmony_ci| INPUT_TIMEOUT                  | 0 | The response to the input event sent to the rendering process times out.  |
8227e41f4b71Sopenharmony_ci| NAVIGATION_COMMIT_TIMEOUT      | 1 | The navigation for loading a new web page times out.  |
8228e41f4b71Sopenharmony_ci
8229e41f4b71Sopenharmony_ci## RenderProcessNotRespondingData<sup>12+</sup>
8230e41f4b71Sopenharmony_ci
8231e41f4b71Sopenharmony_ciProvides detailed information about the unresponsive rendering process.
8232e41f4b71Sopenharmony_ci
8233e41f4b71Sopenharmony_ci| Name                    | Type  | Mandatory| Description                                  |
8234e41f4b71Sopenharmony_ci| ------------------------ | ------ | ---- | -------------------------------------- |
8235e41f4b71Sopenharmony_ci| jsStack      | string | Yes | JavaScript call stack information of the web page.      |
8236e41f4b71Sopenharmony_ci| pid | number | Yes  | Process ID of the web page.|
8237e41f4b71Sopenharmony_ci| reason | [RenderProcessNotRespondingReason](#renderprocessnotrespondingreason12) | Yes  | The reason why the rendering process does not respond.|
8238e41f4b71Sopenharmony_ci
8239e41f4b71Sopenharmony_ci## OnRenderProcessNotRespondingCallback<sup>12+</sup>
8240e41f4b71Sopenharmony_ci
8241e41f4b71Sopenharmony_citype OnRenderProcessNotRespondingCallback = (data : RenderProcessNotRespondingData) => void
8242e41f4b71Sopenharmony_ci
8243e41f4b71Sopenharmony_ciRepresents a callback invoked when the rendering process does not respond.
8244e41f4b71Sopenharmony_ci
8245e41f4b71Sopenharmony_ci| Name              | Type                                       | Description                        |
8246e41f4b71Sopenharmony_ci| -------------------- | ----------------------------------------------- | -------------------------------- |
8247e41f4b71Sopenharmony_ci| data | [RenderProcessNotRespondingData](#renderprocessnotrespondingdata12) | Detailed information about the unresponsive rendering process. |
8248e41f4b71Sopenharmony_ci
8249e41f4b71Sopenharmony_ci## OnRenderProcessRespondingCallback<sup>12+</sup>
8250e41f4b71Sopenharmony_ci
8251e41f4b71Sopenharmony_citype OnRenderProcessRespondingCallback = () => void
8252e41f4b71Sopenharmony_ci
8253e41f4b71Sopenharmony_ciRepresents a callback invoked when the rendering process transitions back to a normal operating state from an unresponsive state.
8254e41f4b71Sopenharmony_ci
8255e41f4b71Sopenharmony_ci## ViewportFit<sup>12+</sup>
8256e41f4b71Sopenharmony_ci
8257e41f4b71Sopenharmony_ciEnumerates the viewport types available for **viewport-fit** in the web page **\<meta>** tag.
8258e41f4b71Sopenharmony_ci
8259e41f4b71Sopenharmony_ci| Name                          | Value| Description          |
8260e41f4b71Sopenharmony_ci| ----------------------------- | -- | ------------ |
8261e41f4b71Sopenharmony_ci| AUTO                  | 0 | The entire web page is visible. Default value.  |
8262e41f4b71Sopenharmony_ci| CONTAINS      | 1 | The initial layout viewport and the visual viewport fit within the largest rectangle that adapts to the device's display screen.  |
8263e41f4b71Sopenharmony_ci| COVER      | 2| The initial layout viewport and the visual viewport are confined within the bounding rectangle of the device's physical screen.  |
8264e41f4b71Sopenharmony_ci
8265e41f4b71Sopenharmony_ci## OnViewportFitChangedCallback<sup>12+</sup>
8266e41f4b71Sopenharmony_ci
8267e41f4b71Sopenharmony_citype OnViewportFitChangedCallback = (viewportFit: ViewportFit) => void
8268e41f4b71Sopenharmony_ci
8269e41f4b71Sopenharmony_ciRepresents the callback invoked when the **viewport-fit** configuration in the web page's **\<meta>** tag changes.
8270e41f4b71Sopenharmony_ci
8271e41f4b71Sopenharmony_ci| Name              | Type                                       | Description                        |
8272e41f4b71Sopenharmony_ci| -------------------- | ----------------------------------------------- | -------------------------------- |
8273e41f4b71Sopenharmony_ci| viewportFit | [ViewportFit](#viewportfit12) | Viewport type for **viewport-fit** in the web page **\<meta>** tag.|
8274e41f4b71Sopenharmony_ci
8275e41f4b71Sopenharmony_ci## ExpandedMenuItemOptions<sup>12+</sup>
8276e41f4b71Sopenharmony_ci
8277e41f4b71Sopenharmony_ciDefines the custom expanded menu options.
8278e41f4b71Sopenharmony_ci
8279e41f4b71Sopenharmony_ci| Name          | Type                                            | Mandatory   | Description            |
8280e41f4b71Sopenharmony_ci| ---------- | -----------------------------------------------------| ------ | ---------------- |
8281e41f4b71Sopenharmony_ci| content   | [ResourceStr](../apis-arkui/arkui-ts/ts-types.md#resourcestr)  | Yes    | Content to display.    |
8282e41f4b71Sopenharmony_ci| startIcon | [ResourceStr](../apis-arkui/arkui-ts/ts-types.md#resourcestr)  | No    | Icon to display.    |
8283e41f4b71Sopenharmony_ci| action    | (selectedText: {plainText: string}) => void                                                         | Yes    | Selected text.|
8284e41f4b71Sopenharmony_ci
8285e41f4b71Sopenharmony_ci## WebKeyboardAvoidMode<sup>12+</sup>
8286e41f4b71Sopenharmony_ci
8287e41f4b71Sopenharmony_ciEnumerates the soft keyboard avoidance modes.
8288e41f4b71Sopenharmony_ci
8289e41f4b71Sopenharmony_ci| Name              | Value| Description          |
8290e41f4b71Sopenharmony_ci| ------------------ | -- | ------------ |
8291e41f4b71Sopenharmony_ci| RESIZE_VISUAL      | 0 | For soft keyboard avoidance, the visual viewport is resized, but not the layout viewport.  |
8292e41f4b71Sopenharmony_ci| RESIZE_CONTENT     | 1 | For soft keyboard avoidance, both the visual viewport and layout viewport are resized. Default value.|
8293e41f4b71Sopenharmony_ci| OVERLAYS_CONTENT   | 2 | No viewport is resized, and soft keyboard avoidance is not triggered.  |
8294e41f4b71Sopenharmony_ci
8295e41f4b71Sopenharmony_ci## OnPageEndEvent<sup>12+</sup>
8296e41f4b71Sopenharmony_ci
8297e41f4b71Sopenharmony_ciRepresents the callback invoked when the web page loading ends.
8298e41f4b71Sopenharmony_ci
8299e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8300e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8301e41f4b71Sopenharmony_ci| url | string | Yes| URL of the page.                      |
8302e41f4b71Sopenharmony_ci
8303e41f4b71Sopenharmony_ci## OnPageBeginEvent<sup>12+</sup>
8304e41f4b71Sopenharmony_ci
8305e41f4b71Sopenharmony_ciRepresents the callback invoked when the web page loading begins.
8306e41f4b71Sopenharmony_ci
8307e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8308e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8309e41f4b71Sopenharmony_ci| url | string | Yes| URL of the page.                      |
8310e41f4b71Sopenharmony_ci
8311e41f4b71Sopenharmony_ci## OnProgressChangeEvent<sup>12+</sup>
8312e41f4b71Sopenharmony_ci
8313e41f4b71Sopenharmony_ciRepresents the callback invoked when the web page loading progress changes.
8314e41f4b71Sopenharmony_ci
8315e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8316e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8317e41f4b71Sopenharmony_ci| newProgress | number | Yes| New loading progress. The value is an integer ranging from 0 to 100.                      |
8318e41f4b71Sopenharmony_ci
8319e41f4b71Sopenharmony_ci## OnTitleReceiveEvent<sup>12+</sup>
8320e41f4b71Sopenharmony_ci
8321e41f4b71Sopenharmony_ciRepresents the callback invoked when the document title of the web page is changed.
8322e41f4b71Sopenharmony_ci
8323e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8324e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8325e41f4b71Sopenharmony_ci| title | string | Yes| Document title.                      |
8326e41f4b71Sopenharmony_ci
8327e41f4b71Sopenharmony_ci## OnGeolocationShowEvent<sup>12+</sup>
8328e41f4b71Sopenharmony_ci
8329e41f4b71Sopenharmony_ciRepresents the callback invoked when a request to obtain the geolocation information is received.
8330e41f4b71Sopenharmony_ci
8331e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8332e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8333e41f4b71Sopenharmony_ci| origin | string | Yes| Index of the origin.                      |
8334e41f4b71Sopenharmony_ci| geolocation | [JsGeolocation](#jsgeolocation) | Yes| User operation.                      |
8335e41f4b71Sopenharmony_ci
8336e41f4b71Sopenharmony_ci## OnAlertEvent<sup>12+</sup>
8337e41f4b71Sopenharmony_ci
8338e41f4b71Sopenharmony_ciRepresents the callback invoked when **alert()** is invoked to display an alert dialog box on the web page.
8339e41f4b71Sopenharmony_ci
8340e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8341e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8342e41f4b71Sopenharmony_ci| url | string | Yes| URL of the web page where the dialog box is displayed.                      |
8343e41f4b71Sopenharmony_ci| message | string | Yes| Message displayed in the dialog box.                      |
8344e41f4b71Sopenharmony_ci| result | [JsResult](#jsresult) | Yes| User operation.                      |
8345e41f4b71Sopenharmony_ci
8346e41f4b71Sopenharmony_ci## OnBeforeUnloadEvent<sup>12+</sup>
8347e41f4b71Sopenharmony_ci
8348e41f4b71Sopenharmony_ciRepresents the callback invoked when this page is about to exit after the user refreshes or closes the page.
8349e41f4b71Sopenharmony_ci
8350e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8351e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8352e41f4b71Sopenharmony_ci| url | string | Yes| URL of the web page where the dialog box is displayed.                      |
8353e41f4b71Sopenharmony_ci| message | string | Yes| Message displayed in the dialog box.                      |
8354e41f4b71Sopenharmony_ci| result | [JsResult](#jsresult) | Yes| User operation.                      |
8355e41f4b71Sopenharmony_ci
8356e41f4b71Sopenharmony_ci## OnConfirmEvent<sup>12+</sup>
8357e41f4b71Sopenharmony_ci
8358e41f4b71Sopenharmony_ciRepresents the callback invoked when **confirm()** is invoked by the web page.
8359e41f4b71Sopenharmony_ci
8360e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8361e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8362e41f4b71Sopenharmony_ci| url | string | Yes| URL of the web page where the dialog box is displayed.                      |
8363e41f4b71Sopenharmony_ci| message | string | Yes| Message displayed in the dialog box.                      |
8364e41f4b71Sopenharmony_ci| result | [JsResult](#jsresult) | Yes| User operation.                      |
8365e41f4b71Sopenharmony_ci
8366e41f4b71Sopenharmony_ci## OnPromptEvent<sup>12+</sup>
8367e41f4b71Sopenharmony_ci
8368e41f4b71Sopenharmony_ciRepresents the callback invoked when **prompt()** is invoked by the web page.
8369e41f4b71Sopenharmony_ci
8370e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8371e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8372e41f4b71Sopenharmony_ci| url | string | Yes| URL of the web page where the dialog box is displayed.                      |
8373e41f4b71Sopenharmony_ci| message | string | Yes| Message displayed in the dialog box.                      |
8374e41f4b71Sopenharmony_ci| result | [JsResult](#jsresult) | Yes| User operation.                      |
8375e41f4b71Sopenharmony_ci
8376e41f4b71Sopenharmony_ci## onConsoleEvent<sup>12+</sup>
8377e41f4b71Sopenharmony_ci
8378e41f4b71Sopenharmony_ciRepresents the callback invoked to notify the host application of a JavaScript console message.
8379e41f4b71Sopenharmony_ci
8380e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8381e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8382e41f4b71Sopenharmony_ci| message | [ConsoleMessage](#consolemessage) | Yes| Console message.                      |
8383e41f4b71Sopenharmony_ci
8384e41f4b71Sopenharmony_ci## OnErrorReceiveEvent<sup>12+</sup>
8385e41f4b71Sopenharmony_ci
8386e41f4b71Sopenharmony_ciRepresents the callback invoked when an error occurs during web page loading.
8387e41f4b71Sopenharmony_ci
8388e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8389e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8390e41f4b71Sopenharmony_ci| request | [WebResourceRequest](#webresourcerequest) | Yes| Encapsulation of a web page request.     |
8391e41f4b71Sopenharmony_ci| error   | [WebResourceError](#webresourceerror)    | Yes| Encapsulation of a web page resource loading error.|
8392e41f4b71Sopenharmony_ci
8393e41f4b71Sopenharmony_ci## OnHttpErrorReceiveEvent<sup>12+</sup>
8394e41f4b71Sopenharmony_ci
8395e41f4b71Sopenharmony_ciRepresents the callback invoked when an HTTP error occurs during web page resource loading.
8396e41f4b71Sopenharmony_ci
8397e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8398e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8399e41f4b71Sopenharmony_ci| request | [WebResourceRequest](#webresourcerequest) | Yes| Encapsulation of a web page request.     |
8400e41f4b71Sopenharmony_ci| response   | [WebResourceResponse](#webresourceresponse)    | Yes| Encapsulation of a resource response.|
8401e41f4b71Sopenharmony_ci
8402e41f4b71Sopenharmony_ci## OnDownloadStartEvent<sup>12+</sup>
8403e41f4b71Sopenharmony_ci
8404e41f4b71Sopenharmony_ciRepresents the callback invoked when the main application starts downloading a file.
8405e41f4b71Sopenharmony_ci
8406e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8407e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8408e41f4b71Sopenharmony_ci| url                | string | Yes| URL for the download task.                          |
8409e41f4b71Sopenharmony_ci| userAgent          | string | Yes| User agent used for download.                         |
8410e41f4b71Sopenharmony_ci| contentDisposition | string | Yes| Content-Disposition response header returned by the server, which may be empty.|
8411e41f4b71Sopenharmony_ci| mimetype           | string | Yes| MIME type of the content returned by the server.               |
8412e41f4b71Sopenharmony_ci| contentLength      | number | Yes| Length of the content returned by the server.                        |
8413e41f4b71Sopenharmony_ci
8414e41f4b71Sopenharmony_ci## OnRefreshAccessedHistoryEvent<sup>12+</sup>
8415e41f4b71Sopenharmony_ci
8416e41f4b71Sopenharmony_ciRepresents the callback invoked when the access history of the web page is refreshed.
8417e41f4b71Sopenharmony_ci
8418e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8419e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8420e41f4b71Sopenharmony_ci| url         | string  | Yes| URL to be accessed.                                 |
8421e41f4b71Sopenharmony_ci| isRefreshed | boolean | Yes| Whether the page is reloaded. The value **true** means that the page is reloaded by invoking the [refresh<sup>9+</sup>](js-apis-webview.md#refresh) API, and **false** means the opposite.|
8422e41f4b71Sopenharmony_ci
8423e41f4b71Sopenharmony_ci## OnRenderExitedEvent<sup>12+</sup>
8424e41f4b71Sopenharmony_ci
8425e41f4b71Sopenharmony_ciRepresents the callback invoked when the rendering process exits.
8426e41f4b71Sopenharmony_ci
8427e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8428e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8429e41f4b71Sopenharmony_ci| renderExitReason | [RenderExitReason](#renderexitreason9) | Yes| Cause for the abnormal exit of the rendering process.|
8430e41f4b71Sopenharmony_ci
8431e41f4b71Sopenharmony_ci## OnShowFileSelectorEvent<sup>12+</sup>
8432e41f4b71Sopenharmony_ci
8433e41f4b71Sopenharmony_ciRepresents the callback invoked to notify the file selector result.
8434e41f4b71Sopenharmony_ci
8435e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8436e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8437e41f4b71Sopenharmony_ci| result       | [FileSelectorResult](#fileselectorresult9) | Yes| File selection result to be sent to the **Web** component.|
8438e41f4b71Sopenharmony_ci| fileSelector | [FileSelectorParam](#fileselectorparam9) | Yes| Information about the file selector.      |
8439e41f4b71Sopenharmony_ci
8440e41f4b71Sopenharmony_ci## onResourceLoadEvent<sup>12+</sup>
8441e41f4b71Sopenharmony_ci
8442e41f4b71Sopenharmony_ciRepresents the callback invoked when the URL is loaded.
8443e41f4b71Sopenharmony_ci
8444e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8445e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8446e41f4b71Sopenharmony_ci| url  | string | Yes| URL of the loaded resource file.|
8447e41f4b71Sopenharmony_ci
8448e41f4b71Sopenharmony_ci## onScaleChangeEvent<sup>12+</sup>
8449e41f4b71Sopenharmony_ci
8450e41f4b71Sopenharmony_ciRepresents the callback invoked when the display scale of this page changes.
8451e41f4b71Sopenharmony_ci
8452e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8453e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8454e41f4b71Sopenharmony_ci| oldScale | number | Yes| Display ratio of the page before the change.|
8455e41f4b71Sopenharmony_ci| newScale | number | Yes| Display ratio of the page after the change.|
8456e41f4b71Sopenharmony_ci
8457e41f4b71Sopenharmony_ci## OnHttpAuthRequestEvent<sup>12+</sup>
8458e41f4b71Sopenharmony_ci
8459e41f4b71Sopenharmony_ciRepresents the callback invoked when an HTTP authentication request is received.
8460e41f4b71Sopenharmony_ci
8461e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8462e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8463e41f4b71Sopenharmony_ci| handler | [HttpAuthHandler](#httpauthhandler9) | Yes| User operation.  |
8464e41f4b71Sopenharmony_ci| host    | string                               | Yes| Host to which HTTP authentication credentials apply.|
8465e41f4b71Sopenharmony_ci| realm   | string                               | Yes| Realm to which HTTP authentication credentials apply. |
8466e41f4b71Sopenharmony_ci
8467e41f4b71Sopenharmony_ci## OnInterceptRequestEvent<sup>12+</sup>
8468e41f4b71Sopenharmony_ci
8469e41f4b71Sopenharmony_ciRepresents the callback invoked when the **Web** component is about to load a URL.
8470e41f4b71Sopenharmony_ci
8471e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8472e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8473e41f4b71Sopenharmony_ci| request | [WebResourceRequest](#webresourcerequest) | Yes| Information about the URL request.|
8474e41f4b71Sopenharmony_ci
8475e41f4b71Sopenharmony_ci## onPermissionRequestEvent<sup>12+</sup>
8476e41f4b71Sopenharmony_ci
8477e41f4b71Sopenharmony_ciRepresents the callback invoked when a permission request is received.
8478e41f4b71Sopenharmony_ci
8479e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8480e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8481e41f4b71Sopenharmony_ci| request | [PermissionRequest](#permissionrequest9) | Yes| User operation.|
8482e41f4b71Sopenharmony_ci
8483e41f4b71Sopenharmony_ci## onScreenCaptureRequestEvent<sup>12+</sup>
8484e41f4b71Sopenharmony_ci
8485e41f4b71Sopenharmony_ciRepresents the callback invoked when a screen capture request is received.
8486e41f4b71Sopenharmony_ci
8487e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8488e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8489e41f4b71Sopenharmony_ci| handler | [ScreenCaptureHandler](#screencapturehandler10) | Yes| User operation.|
8490e41f4b71Sopenharmony_ci
8491e41f4b71Sopenharmony_ci## onContextMenuShowEvent<sup>12+</sup>
8492e41f4b71Sopenharmony_ci
8493e41f4b71Sopenharmony_ciRepresents the callback invoked during a call to allow for the display of a custom context menu.
8494e41f4b71Sopenharmony_ci
8495e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8496e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8497e41f4b71Sopenharmony_ci| param  | [WebContextMenuParam](#webcontextmenuparam9) | Yes| Parameters related to the context menu.    |
8498e41f4b71Sopenharmony_ci| result | [WebContextMenuResult](#webcontextmenuresult9) | Yes| Result of the context menu.|
8499e41f4b71Sopenharmony_ci
8500e41f4b71Sopenharmony_ci## onSearchResultReceiveEvent<sup>12+</sup>
8501e41f4b71Sopenharmony_ci
8502e41f4b71Sopenharmony_ciRepresents the callback invoked to notify the caller of the search result on the web page.
8503e41f4b71Sopenharmony_ci
8504e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8505e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8506e41f4b71Sopenharmony_ci| activeMatchOrdinal | number  | Yes| Sequence number of the current match, which starts from 0.                      |
8507e41f4b71Sopenharmony_ci| numberOfMatches    | number  | Yes| Total number of matches.                           |
8508e41f4b71Sopenharmony_ci| isDoneCounting     | boolean | Yes| Whether the search operation on the current page is complete. This API may be called multiple times until **isDoneCounting** is **true**.|
8509e41f4b71Sopenharmony_ci
8510e41f4b71Sopenharmony_ci## onScrollEvent<sup>12+</sup>
8511e41f4b71Sopenharmony_ci
8512e41f4b71Sopenharmony_ciRepresents the callback invoked when the scrollbar scrolls to a specified position.
8513e41f4b71Sopenharmony_ci
8514e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8515e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8516e41f4b71Sopenharmony_ci| xOffset | number | Yes| Position of the scrollbar on the x-axis relative to the leftmost of the web page.|
8517e41f4b71Sopenharmony_ci| yOffset | number | Yes| Position of the scrollbar on the y-axis relative to the top of the web page.|
8518e41f4b71Sopenharmony_ci
8519e41f4b71Sopenharmony_ci## OnSslErrorEventReceiveEvent<sup>12+</sup>
8520e41f4b71Sopenharmony_ci
8521e41f4b71Sopenharmony_ciRepresents the callback invoked when the web page receives an SSL error.
8522e41f4b71Sopenharmony_ci
8523e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8524e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8525e41f4b71Sopenharmony_ci| handler | [SslErrorHandler](#sslerrorhandler9) | Yes| User operation.|
8526e41f4b71Sopenharmony_ci| error   | [SslError](#sslerror9)          | Yes| Error code.          |
8527e41f4b71Sopenharmony_ci
8528e41f4b71Sopenharmony_ci## onClientAuthenticationRequestEvent<sup>12+</sup>
8529e41f4b71Sopenharmony_ci
8530e41f4b71Sopenharmony_ciRepresents the callback invoked when an SSL client certificate is required from the user.
8531e41f4b71Sopenharmony_ci
8532e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8533e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8534e41f4b71Sopenharmony_ci| handler  | [ClientAuthenticationHandler](#clientauthenticationhandler9) | Yes| User operation. |
8535e41f4b71Sopenharmony_ci| host     | string                                   | Yes| Host name of the server that requests a certificate.   |
8536e41f4b71Sopenharmony_ci| port     | number                                   | Yes| Port number of the server that requests a certificate.   |
8537e41f4b71Sopenharmony_ci| keyTypes | Array<string\>                           | Yes| Acceptable asymmetric private key types.   |
8538e41f4b71Sopenharmony_ci| issuers  | Array<string\>                           | Yes| Issuer of the certificate that matches the private key.|
8539e41f4b71Sopenharmony_ci
8540e41f4b71Sopenharmony_ci## OnWindowNewEvent<sup>12+</sup>
8541e41f4b71Sopenharmony_ci
8542e41f4b71Sopenharmony_ciRepresents the callback invoked when the web page requests the user to create a new window.
8543e41f4b71Sopenharmony_ci
8544e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8545e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8546e41f4b71Sopenharmony_ci| isAlert       | boolean                                  | Yes| Whether to open the target URL in a new window. The value **true** means to open the target URL in a new window, and **false** means to open the target URL in a new tab.   |
8547e41f4b71Sopenharmony_ci| isUserTrigger | boolean                                  | Yes| Whether the creation is triggered by the user. The value **true** means that the creation is triggered by the user, and **false** means the opposite.     |
8548e41f4b71Sopenharmony_ci| targetUrl     | string                                   | Yes| Target URL.                       |
8549e41f4b71Sopenharmony_ci| handler       | [ControllerHandler](#controllerhandler9) | Yes| **WebviewController** instance for setting the new window.|
8550e41f4b71Sopenharmony_ci
8551e41f4b71Sopenharmony_ci## onTouchIconUrlReceivedEvent<sup>12+</sup>
8552e41f4b71Sopenharmony_ci
8553e41f4b71Sopenharmony_ciRepresents the callback invoked when an apple-touch-icon URL is received.
8554e41f4b71Sopenharmony_ci
8555e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8556e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8557e41f4b71Sopenharmony_ci| url         | string  | Yes| Received apple-touch-icon URL.|
8558e41f4b71Sopenharmony_ci| precomposed | boolean | Yes| Whether the apple-touch-icon is precomposed.  |
8559e41f4b71Sopenharmony_ci
8560e41f4b71Sopenharmony_ci## onFaviconReceivedEvent<sup>12+</sup>
8561e41f4b71Sopenharmony_ci
8562e41f4b71Sopenharmony_ciRepresents the callback invoked when this web page receives a new favicon.
8563e41f4b71Sopenharmony_ci
8564e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8565e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8566e41f4b71Sopenharmony_ci| favicon | [PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes| **PixelMap** object of the received favicon.|
8567e41f4b71Sopenharmony_ci
8568e41f4b71Sopenharmony_ci## onPageVisibleEvent<sup>12+</sup>
8569e41f4b71Sopenharmony_ci
8570e41f4b71Sopenharmony_ciRepresents the callback invoked when the old page is not displayed and the new page is about to be visible.
8571e41f4b71Sopenharmony_ci
8572e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8573e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8574e41f4b71Sopenharmony_ci| url  | string | Yes| URL of the new page that is able to be visible when the old page is not displayed.|
8575e41f4b71Sopenharmony_ci
8576e41f4b71Sopenharmony_ci## onDataResubmittedEvent<sup>12+</sup>
8577e41f4b71Sopenharmony_ci
8578e41f4b71Sopenharmony_ciRepresents the callback invoked when the web form data can be resubmitted.
8579e41f4b71Sopenharmony_ci
8580e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8581e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8582e41f4b71Sopenharmony_ci| handler | [DataResubmissionHandler](#dataresubmissionhandler9) | Yes| Handler for resubmitting web form data.|
8583e41f4b71Sopenharmony_ci
8584e41f4b71Sopenharmony_ci## onAudioStateChangedEvent<sup>12+</sup>
8585e41f4b71Sopenharmony_ci
8586e41f4b71Sopenharmony_ciRepresents the callback invoked when the audio playback status on the web page changes.
8587e41f4b71Sopenharmony_ci
8588e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8589e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8590e41f4b71Sopenharmony_ci| playing | boolean | Yes| Audio playback status on the current page. The value **true** means that audio is being played, and **false** means the opposite.|
8591e41f4b71Sopenharmony_ci
8592e41f4b71Sopenharmony_ci## onFirstContentfulPaintEvent<sup>12+</sup>
8593e41f4b71Sopenharmony_ci
8594e41f4b71Sopenharmony_ciRepresents the callback invoked when the first content paint occurs on the web page.
8595e41f4b71Sopenharmony_ci
8596e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8597e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8598e41f4b71Sopenharmony_ci| navigationStartTick    | number | Yes| Navigation start time, in microseconds.         |
8599e41f4b71Sopenharmony_ci| firstContentfulPaintMs | number | Yes| Time between navigation and when the content is first rendered, in milliseconds.|
8600e41f4b71Sopenharmony_ci
8601e41f4b71Sopenharmony_ci## onLoadInterceptEvent<sup>12+</sup>
8602e41f4b71Sopenharmony_ci
8603e41f4b71Sopenharmony_ciRepresents the callback invoked when the **Web** component is about to access a URL.
8604e41f4b71Sopenharmony_ci
8605e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8606e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8607e41f4b71Sopenharmony_ci| data | [WebResourceRequest](#webresourcerequest) | Yes| Information about the URL request.|
8608e41f4b71Sopenharmony_ci
8609e41f4b71Sopenharmony_ci## onOverScrollEvent<sup>12+</sup>
8610e41f4b71Sopenharmony_ci
8611e41f4b71Sopenharmony_ciRepresents the callback invoked when the web page is overscrolled.
8612e41f4b71Sopenharmony_ci
8613e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8614e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8615e41f4b71Sopenharmony_ci| xOffset | number | Yes| Horizontal overscroll offset based on the leftmost edge of the web page.|
8616e41f4b71Sopenharmony_ci| yOffset | number | Yes| Vertical overscroll offset based on the top edge of the web page.|
8617e41f4b71Sopenharmony_ci
8618e41f4b71Sopenharmony_ci## JavaScriptProxy<sup>12+</sup>
8619e41f4b71Sopenharmony_ci
8620e41f4b71Sopenharmony_ciDefines the JavaScript object to be injected.
8621e41f4b71Sopenharmony_ci
8622e41f4b71Sopenharmony_ci| Name            | Type     | Mandatory  | Description                                      |
8623e41f4b71Sopenharmony_ci| -------------- | ---- | ---- | ---------------------------------------- |
8624e41f4b71Sopenharmony_ci| object     | object                                   | Yes   | Object to be registered. Methods can be declared, but attributes cannot.                  |
8625e41f4b71Sopenharmony_ci| name       | string                                   | Yes   | Name of the object to be registered, which is the same as that invoked in the window.               |
8626e41f4b71Sopenharmony_ci| methodList | Array\<string\>                          | Yes   | Synchronous methods of the JavaScript object to be registered at the application side.                |
8627e41f4b71Sopenharmony_ci| controller | [WebviewController<sup>9+</sup>](js-apis-webview.md#webviewcontroller) \| [WebController](#webcontroller) | Yes   | -    | Controller. This API is deprecated since API version 9. You are advised to use **WebviewController** instead.|
8628e41f4b71Sopenharmony_ci| asyncMethodList<sup>12+</sup>  | Array\<string\>      | No   | Asynchronous methods of the JavaScript object to be registered at the application side. Asynchronous methods do not provide return values.  |
8629e41f4b71Sopenharmony_ci| permission<sup>12+</sup>  | string  | No   | JSON string, which is empty by default. This string is used to configure JSBridge permission control and define the URL trustlist at the object and method levels.<br>For the example, see [Invoking Application Functions on the Frontend Page](../../web/web-in-page-app-function-invoking.md). |
8630e41f4b71Sopenharmony_ci
8631e41f4b71Sopenharmony_ci## AdsBlockedDetails<sup>12+</sup>
8632e41f4b71Sopenharmony_ci
8633e41f4b71Sopenharmony_ciProvides detailed information about the blocked ads when ads are blocked.
8634e41f4b71Sopenharmony_ci
8635e41f4b71Sopenharmony_ci| Name| Type                                                                         | Description                   |
8636e41f4b71Sopenharmony_ci| ------- | -------------------------------------------------------------------------------- | ------------------------- |
8637e41f4b71Sopenharmony_ci| url | string  | URL of the page where ads are blocked.|
8638e41f4b71Sopenharmony_ci| adsBlocked | Array\<string\>  | URLs or DOMPath of the blocked ads. If ads have the same URLs, duplicate elements may exist.|
8639e41f4b71Sopenharmony_ci
8640e41f4b71Sopenharmony_ci## OnAdsBlockedCallback<sup>12+</sup>
8641e41f4b71Sopenharmony_ci
8642e41f4b71Sopenharmony_citype OnAdsBlockedCallback = (details: AdsBlockedDetails) => void
8643e41f4b71Sopenharmony_ci
8644e41f4b71Sopenharmony_ciRepresents the callback invoked when ads are blocked on the web page.
8645e41f4b71Sopenharmony_ci**Parameters**
8646e41f4b71Sopenharmony_ci
8647e41f4b71Sopenharmony_ci| Name              | Type                                       | Description                        |
8648e41f4b71Sopenharmony_ci| -------------------- | ----------------------------------------------- | -------------------------------- |
8649e41f4b71Sopenharmony_ci| details | [AdsBlockedDetails](#adsblockeddetails12) | Detailed information about the blocked ads when ads are blocked.|
8650e41f4b71Sopenharmony_ci
8651e41f4b71Sopenharmony_ci## NativeEmbedVisibilityInfo<sup>12+</sup>
8652e41f4b71Sopenharmony_ci
8653e41f4b71Sopenharmony_ciProvides visibility information of the **embed** tag.
8654e41f4b71Sopenharmony_ci
8655e41f4b71Sopenharmony_ci| Name          | Type                               | Mandatory  | Description             |
8656e41f4b71Sopenharmony_ci| -------------  | ------------------------------------| ----- | ------------------ |
8657e41f4b71Sopenharmony_ci| visibility     | boolean                             | No    | Whether the **embed** tag is visible.        |
8658e41f4b71Sopenharmony_ci| embedId        | string                              | No    | ID of the same-layer rendering tag. |
8659e41f4b71Sopenharmony_ci
8660e41f4b71Sopenharmony_ci## OnNativeEmbedVisibilityChangeCallback<sup>12+</sup>
8661e41f4b71Sopenharmony_ci
8662e41f4b71Sopenharmony_citype OnNativeEmbedVisibilityChangeCallback = (nativeEmbedVisibilityInfo: NativeEmbedVisibilityInfo) => void
8663e41f4b71Sopenharmony_ci
8664e41f4b71Sopenharmony_ciRepresents the callback invoked when the visibility of an **embed** tag changes.
8665e41f4b71Sopenharmony_ci
8666e41f4b71Sopenharmony_ci| Name  | Type                                                                         | Description                   |
8667e41f4b71Sopenharmony_ci| ------- | -------------------------------------------------------------------------------- | ------------------------- |
8668e41f4b71Sopenharmony_ci| nativeEmbedVisibilityInfo | [NativeEmbedVisibilityInfo](#nativeembedvisibilityinfo12)  | The visibility information about the **embed** tag.|
8669