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