letisSupportTpl:boolean=data;// The value **true** means that the template of the **downloadTemplate** type is supported; and false means the opposite.
letisSupportTpl:boolean=data;// The value true means that the template of the downloadTemplate type is supported, and false means the opposite.
// ...
// ...
}).catch((err)=>{
}).catch((err)=>{
console.error(`[ANS] isSupportTemplate failed, code is ${err.code}, message is ${err.message}`);
console.error(`[ANS] isSupportTemplate failed, code is ${err.code}, message is ${err.message}`);
The **Webview** module provides APIs for web control.
The **Webview** module provides APIs for web control. It can be used with the **[<Web\>](../arkui-ts/ts-basic-components-web.md)** component, which can be used to display web pages.
> **NOTE**
> **NOTE**
>
>
...
@@ -20,7 +20,7 @@ The **Webview** module provides APIs for web control.
...
@@ -20,7 +20,7 @@ The **Webview** module provides APIs for web control.
Theh5Port=event.ports[0];// 1. Save the port number sent from the eTS side.
h5Port=event.ports[0];// 1. Save the port number sent from the eTS side.
h5Port.onmessage=function(event){
h5Port.onmessage=function(event){
// 2. Receive the message sent from the eTS side.
// 2. Receive the message sent from the eTS side.
varmsg='Got message from ets:';
varmsg='Got message from ets:';
...
@@ -3167,6 +3258,358 @@ struct WebComponent {
...
@@ -3167,6 +3258,358 @@ struct WebComponent {
}
}
```
```
### getCertificate<sup>10+</sup>
getCertificate(): Promise<Array<cert.X509Cert>>
Obtains the certificate information of the current website. When the \<Web> component is used to load an HTTPS website, SSL certificate verification is performed. This API uses a promise to return the [X.509 certificate](./js-apis-cert.md) of the current website.
Obtains the certificate information of the current website. When the \<Web> component is used to load an HTTPS website, SSL certificate verification is performed. This API uses an asynchronous callback to return the [X.509 certificate](./js-apis-cert.md) of the current website.
Implements a **WebCookieManager** instance to manage behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookieManager** instance.
Implements a **WebCookieManager** instance to manage behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookieManager** instance.
| boolean | Whether any saved HTTP authentication credentials exist. Returns **true** if any saved HTTP authentication credentials exist; returns **false** otherwise.|
| boolean | Whether any saved HTTP authentication credentials exist. Returns **true** if any saved HTTP authentication credentials exist; returns **false** otherwise.|
**Example**
**Example**
...
@@ -4771,3 +5211,15 @@ Defines a custom URL scheme.
...
@@ -4771,3 +5211,15 @@ Defines a custom URL scheme.
| schemeName | string | Yes | Yes | Name of the custom URL scheme. The value can contain a maximum of 32 characters and include only lowercase letters, digits, periods (.), plus signs (+), and hyphens (-). |
| schemeName | string | Yes | Yes | Name of the custom URL scheme. The value can contain a maximum of 32 characters and include only lowercase letters, digits, periods (.), plus signs (+), and hyphens (-). |
| isSupportCORS | boolean | Yes | Yes | Whether to support cross-origin resource sharing (CORS). |
| isSupportCORS | boolean | Yes | Yes | Whether to support cross-origin resource sharing (CORS). |
| isSupportFetch | boolean | Yes | Yes | Whether to support fetch requests. |
| isSupportFetch | boolean | Yes | Yes | Whether to support fetch requests. |
## SecureDnsMode<sup>10+</sup>
Describes the mode in which the **\<Web>** component uses HTTPDNS.
| Off | 0 |HTTPDNS is not used. This value can be used to revoke the previously used HTTPDNS configuration.|
| Auto | 1 |HTTPDNS is used in automatic mode. When the specified HTTPDNS server is unavailable for resolution, the component will fall back to the system DNS server.|
| SecureOnly | 2 |The specified HTTPDNS server is forcibly used for DNS resolution.|
The **<Web\>** component can be used to display web pages.
The **<Web\>** component can be used to display web pages. It can be used with the [@ohos.web.webview](../apis/js-apis-webview.md) module, which provides APIs for web control.
| src | [ResourceStr](ts-types.md) | Yes | Address of a web page resource.|
| src | [ResourceStr](ts-types.md) | Yes | Address of a web page resource. To access local resource files, use the **$rawfile** or **resource** protocol.|
| controller | [WebviewController<sup>9+</sup>](../apis/js-apis-webview.md#webviewcontroller)\|[WebController](#webcontroller) | Yes | Controller. **WebController** is deprecated since API version 9. You are advised to use **WebviewController** instead.|
| controller | [WebviewController<sup>9+</sup>](../apis/js-apis-webview.md#webviewcontroller)\|[WebController](#webcontroller) | Yes | - | Controller. **WebController** is deprecated since API version 9. You are advised to use **WebviewController** instead.|
@StateuserAgent:string='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'
@StateuserAgent:string='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'
build(){
build(){
Column(){
Column(){
...
@@ -1196,7 +1209,9 @@ This API opens a new window when [multiWindowAccess](#multiwindowaccess9) is ena
...
@@ -1196,7 +1209,9 @@ This API opens a new window when [multiWindowAccess](#multiwindowaccess9) is ena
The 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**.
The 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**.
To check the settings of **persist.web.allowWindowOpenMethod.enabled**, run the **hdc shell param get persist.web.allowWindowOpenMethod.enabled** command. If the attribute is set to 0 or does not exist,
To check the settings of **persist.web.allowWindowOpenMethod.enabled**,
run the **hdc shell param get persist.web.allowWindowOpenMethod.enabled** command. If the attribute is set to 0 or does not exist,
you can run the **hdc shell param set persist.web.allowWindowOpenMethod.enabled 1** command to enable it.
you can run the **hdc shell param set persist.web.allowWindowOpenMethod.enabled 1** command to enable it.
**Parameters**
**Parameters**
...
@@ -1256,10 +1271,12 @@ Called when **alert()** is invoked to display an alert dialog box on the web pag
...
@@ -1256,10 +1271,12 @@ Called when **alert()** is invoked to display an alert dialog box on the web pag
@Statemessage:string='Hello World'// message is used for debugging and observation.
certManager=CertManagerService.getInstance();
build(){
Row(){
Column(){
Row(){
// Step 1: Perform authorization to obtain the URI.
Button('GrantApp')
.onClick(()=>{
this.certManager.grantAppPm((data)=>{
this.message=data;
});
})
// Step 2: After the authorization, in two-way authentication, the onClientAuthenticationRequest callback is used to send the URI to the web server for authentication.
Button("ClientCertAuth")
.onClick(()=>{
this.controller.loadUrl('https://www.example2.com');// Server website that supports two-way authentication.
@@ -2525,7 +2692,7 @@ Registers a callback for window creation.
...
@@ -2525,7 +2692,7 @@ Registers a callback for window creation.
| isAlert | boolean | 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.|
| isAlert | boolean | 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.|
| isUserTrigger | boolean | 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. |
| isUserTrigger | boolean | 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. |
| targetUrl | string | Target URL. |
| targetUrl | string | Target URL. |
| handler | [ControllerHandler](#controllerhandler9) | **WebController** instance for setting the new window. |
| handler | [ControllerHandler](#controllerhandler9) | **WebviewController** instance for setting the new window. |
**Example**
**Example**
...
@@ -2566,10 +2733,12 @@ Registers a callback for window closure.
...
@@ -2566,10 +2733,12 @@ Registers a callback for window closure.
| playing | boolean | Audio playback status on the current page. The value **true** means that audio is being played, and **false** means the opposite.|
| 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>](../apis/js-apis-webview.md#geolocationpermissions).|
| 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>](../apis/js-apis-webview.md#geolocationpermissions).|
## WebController
## MessageLevel
| Name | Description |
| ----- | :---- |
| Debug | Debug level.|
| Error | Error level.|
| Info | Information level.|
| Log | Log level.|
| Warn | Warning level. |
## RenderExitReason
Enumerates the reasons why the rendering process exits.
| Default | The cache that has not expired is used to load the resources. If the resources do not exist in the cache, they will be obtained from the Internet.|
| None | The cache is used to load the resources. If the resources do not exist in the cache, they will be obtained from the Internet. |
| Online | The cache is not used to load the resources. All resources are obtained from the Internet. |
| Only | The cache alone is used to load the resources. |
## FileSelectorMode
| Name | Description |
| -------------------- | ---------- |
| FileOpenMode | Open and upload a file. |
| FileOpenMultipleMode | Open and upload multiple files. |
| FileOpenFolderMode | Open and upload a folder.|
| FileSaveMode | Save a file. |
## HitTestType
| Name | Description |
| ------------- | ------------------------ |
| EditText | Editable area. |
| Email | Email address. |
| HttpAnchor | Hyperlink whose **src** is **http**. |
| HttpAnchorImg | Image with a hyperlink, where **src** is **http**.|
| Img | HTML::img tag. |
| Map | Geographical address. |
| Phone | Phone number. |
| Unknown | Unknown content. |
## SslError<sup>9+</sup>
Enumerates the error codes returned by **onSslErrorEventReceive** API.
| Name | Description |
| ------------ | ----------- |
| Invalid | Minor error. |
| HostMismatch | The host name does not match. |
| DateInvalid | The certificate has an invalid date. |
| Untrusted | The certificate issuer is not trusted.|
Implements 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.
Implements 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.
...
@@ -3600,6 +3970,39 @@ This API is deprecated since API version 9. You are advised to use [WebviewContr
...
@@ -3600,6 +3970,39 @@ This API is deprecated since API version 9. You are advised to use [WebviewContr
webController: WebController = new WebController()
webController: WebController = new WebController()
```
```
### getCookieManager<sup>9+</sup>
getCookieManager(): WebCookie
Obtains the cookie management object of the **\<Web>** component.
Manages 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.
Manages 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.
### setCookie<sup>9+</sup>
### setCookie<sup>(deprecated)</sup>
setCookie(url: string, value: string): boolean
setCookie(url: string, value: string): boolean
Sets the cookie. This API returns the result synchronously. Returns **true** if the operation is successful; returns **false** otherwise.
Sets the cookie. This API returns the result synchronously. Returns **true** if the operation is successful; returns **false** otherwise.
This API is deprecated since API version 9. You are advised to use [setCookie<sup>9+</sup>](../apis/js-apis-webview.md#setcookie) instead.
**Parameters**
**Parameters**
...
@@ -4371,7 +4709,7 @@ Sets the cookie. This API returns the result synchronously. Returns **true** if
...
@@ -4371,7 +4709,7 @@ Sets the cookie. This API returns the result synchronously. Returns **true** if
| Default | The cache that has not expired is used to load the resources. If the resources do not exist in the cache, they will be obtained from the Internet.|
| None | The cache is used to load the resources. If the resources do not exist in the cache, they will be obtained from the Internet. |
| Online | The cache is not used to load the resources. All resources are obtained from the Internet. |
| Only | The cache alone is used to load the resources. |
## FileSelectorMode
| Name | Description |
| -------------------- | ---------- |
| FileOpenMode | Open and upload a file. |
| FileOpenMultipleMode | Open and upload multiple files. |
| FileOpenFolderMode | Open and upload a folder.|
| FileSaveMode | Save a file. |
## HitTestType
| Name | Description |
| ------------- | ------------------------ |
| EditText | Editable area. |
| Email | Email address. |
| HttpAnchor | Hyperlink whose **src** is **http**. |
| HttpAnchorImg | Image with a hyperlink, where **src** is **http**.|
| Img | HTML::img tag. |
| Map | Geographical address. |
| Phone | Phone number. |
| Unknown | Unknown content. |
## SslError<sup>9+</sup>
Enumerates the error codes returned by **onSslErrorEventReceive** API.
| Name | Description |
| ------------ | ----------- |
| Invalid | Minor error. |
| HostMismatch | The host name does not match. |
| DateInvalid | The certificate has an invalid date. |
| Untrusted | The certificate issuer is not trusted.|