+
+
+
+```
+
### deleteJavaScriptRegister
deleteJavaScriptRegister(name: string): void
@@ -1565,12 +2028,18 @@ struct WebComponent {
### createWebMessagePorts
- createWebMessagePorts(): Array\
+createWebMessagePorts(isExtentionType?: boolean): Array\
-Creates web message ports.
+Creates web message ports. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
**System capability**: SystemCapability.Web.Webview.Core
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ---------------------- | ---- | :------------------------------|
+| isExtentionType10+ | boolean | No | Whether to use the extended interface. The default value is **false**, indicating that the extended interface is not used.|
+
**Return value**
| Type | Description |
@@ -1626,8 +2095,8 @@ Sends a web message to an HTML5 window.
| Name| Type | Mandatory| Description |
| ------ | ---------------------- | ---- | :------------------------------- |
-| name | string | Yes | Message to send, including the data and message port.|
-| ports | Array\ | Yes | Ports for receiving the message. |
+| name | string | Yes | Name of the message to send. |
+| ports | Array\ | Yes | Message ports for sending the message. |
| uri | string | Yes | URI for receiving the message. |
**Error codes**
@@ -1739,9 +2208,9 @@ var output = document.querySelector('.output');
window.addEventListener('message', function (event) {
if (event.data == '__init_port__') {
if (event.ports[0] != null) {
- h5Port = event.ports[0]; // 1. Save the port number sent from the ArkTS side.
+ h5Port = event.ports[0]; // 1. Save the port number sent from the eTS side.
h5Port.onmessage = function (event) {
- // 2. Receive the message sent from the ArkTS side.
+ // 2. Receive the message sent from the eTS side.
var msg = 'Got message from ets:';
var result = event.data;
if (typeof(result) == "string") {
@@ -1763,7 +2232,7 @@ window.addEventListener('message', function (event) {
}
})
-// 3. Use h5Port to send messages to the ArkTS side.
+// 3. Use h5Port to send messages to the eTS side.
function PostMsgToEts(data) {
if (h5Port) {
h5Port.postMessage(data);
@@ -3572,7 +4041,7 @@ struct Index {
}
```
-### setAudioMuted
+### setAudioMuted10+
setAudioMuted(mute: boolean): void
@@ -3586,6 +4055,14 @@ Mutes this web page.
| -------- | ------- | ---- | -------------------------------------- |
| mute | boolean | Yes | Whether to mute the web page. The value **true** means to mute the web page, and **false** means the opposite.|
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------------------------------ |
+| 17100001 | Init error. The WebviewController must be associated with a Web component. |
+
**Example**
```ts
@@ -3618,7 +4095,7 @@ Implements a **WebCookieManager** instance to manage behavior of cookies in **\<
static getCookie(url: string): string
-Obtains the cookie value corresponding to the specified URL.
+Obtains the cookie corresponding to the specified URL.
**System capability**: SystemCapability.Web.Webview.Core
@@ -3626,7 +4103,7 @@ Obtains the cookie value corresponding to the specified URL.
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | :------------------------ |
-| url | string | Yes | URL of the cookie value to obtain. A complete URL is recommended.|
+| url | string | Yes | URL of the cookie to obtain. A complete URL is recommended.|
**Return value**
@@ -3674,7 +4151,7 @@ struct WebComponent {
static setCookie(url: string, value: string): void
-Sets a cookie value for the specified URL.
+Sets a cookie for the specified URL.
**System capability**: SystemCapability.Web.Webview.Core
@@ -3867,7 +4344,7 @@ Checks whether the **WebCookieManager** instance has the permission to send and
| Type | Description |
| ------- | -------------------------------- |
-| boolean | Whether the **WebCookieManager** instance has the permission to send and receive cookies.|
+| boolean | Whether the **WebCookieManager** instance has the permission to send and receive cookies. The default value is **true**.|
**Example**
@@ -3946,7 +4423,7 @@ Checks whether the **WebCookieManager** instance has the permission to send and
| Type | Description |
| ------- | -------------------------------------- |
-| boolean | Whether the **WebCookieManager** instance has the permission to send and receive third-party cookies.|
+| boolean | Whether the **WebCookieManager** instance has the permission to send and receive third-party cookies. The default value is **false**.|
**Example**
@@ -5112,6 +5589,463 @@ Describes the data types supported for [WebMessagePort](#webmessageport).
| string | String type.|
| ArrayBuffer | Binary type.|
+## JsMessageType10+
+
+Describes the type of the returned result of script execution using [runJavaScirptExt](#runjavascriptext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+| Name | Value| Description |
+| ------------ | -- |--------------------------------- |
+| NOT_SUPPORT | 0 |Unsupported data type.|
+| STRING | 1 |String type.|
+| NUMBER | 2 |Number type.|
+| BOOLEAN | 3 |Boolean type.|
+| ARRAY_BUFFER | 4 |Raw binary data buffer.|
+| ARRAY | 5 |Array type.|
+
+
+## WebMessageType10+
+
+Describes the data type supported by the [webMessagePort](#webmessageport) API.
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+| Name | Value| Description |
+| ------------ | -- |------------------------------- |
+| NOT_SUPPORT | 0 |Unsupported data type.|
+| STRING | 1 |String type.|
+| NUMBER | 2 |Number type.|
+| BOOLEAN | 3 |Boolean type.|
+| ARRAY_BUFFER | 4 |Raw binary data buffer.|
+| ARRAY | 5 |Array type.|
+| ERROR | 6 |Error object type.|
+
+## JsMessageExt10+
+
+Implements the **JsMessageExt** data object that is returned after script execution using the [runJavaScirptExt](#runjavascriptext10) API.
+
+### getType10+
+
+getType(): JsMessageType
+
+Obtains the type of the data object.
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| --------------------------------------------------------- |
+| [JsMessageType](#jsmessagetype10) | Type of the data object that is returned after script execution using the [runJavaScirptExt](#runjavascriptext10) API.|
+
+### getString10+
+
+getString(): string
+
+Obtains string-type data of the data object. For the complete sample code, see [runJavaScriptExt](#runjavascriptext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| string | Data of the string type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the result. |
+
+
+### getNumber10+
+
+getNumber(): number
+
+Obtains number-type data of the data object. For the complete sample code, see [runJavaScriptExt](#runjavascriptext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| number | Data of the number type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the result. |
+
+### getBoolean10+
+
+getBoolean(): boolean
+
+Obtains Boolean-type data of the data object. For the complete sample code, see [runJavaScriptExt](#runjavascriptext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| boolean | Data of the Boolean type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the result. |
+
+
+### getArrayBuffer10+
+
+getArrayBuffer(): ArrayBuffer
+
+Obtains raw binary data of the data object. For the complete sample code, see [runJavaScriptExt](#runjavascriptext10).
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| ArrayBuffer | Raw binary data.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the result. |
+
+### getArray10+
+
+getArray(): Array\
+
+Obtains array-type data of the data object. For the complete sample code, see [runJavaScriptExt](#runjavascriptext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| Array\ | Data of the array type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the result. |
+
+
+## WebMessageExt10+
+
+Data object received and sent by the [webMessagePort](#webmessageport) interface.
+
+### getType10+
+
+getType(): WebMessageType
+
+Obtains the type of the data object.
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| --------------------------------------------------------- |
+| [WebMessageType](#webmessagetype10) | Data type supported by the [webMessagePort](#webmessageport) API.|
+
+
+### getString10+
+
+getString(): string
+
+Obtains string-type data of the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| string | Data of the string type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+
+### getNumber10+
+
+getNumber(): number
+
+Obtains number-type data of the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| number | Data of the number type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+
+### getBoolean10+
+
+getBoolean(): boolean
+
+Obtains Boolean-type data of the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| boolean | Data of the Boolean type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+
+### getArrayBuffer10+
+
+getArrayBuffer(): ArrayBuffer
+
+Obtains raw binary data of the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| ArrayBuffer | Raw binary data.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+### getArray10+
+
+getArray(): Array\
+
+Obtains array-type data of the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| Array\ | Data of the array type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+### getError10+
+
+getError(): Error
+
+Obtains the error-object-type data of the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Return value**
+
+| Type | Description |
+| --------------| ------------- |
+| Error | Data of the error object type.|
+
+**Error codes**
+
+For details about the error codes, see [Webview Error Codes](../errorcodes/errorcode-webview.md).
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+
+### setType10+
+
+setType(type: WebMessageType): void
+
+Sets the type for the data object.
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------------- |
+| type | [WebMessageType](#webmessagetype10) | Yes | Data type supported by the [webMessagePort](#webmessageport) API.|
+
+**Error codes**
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+### setString10+
+
+setString(message: string): void
+
+Sets the string-type data of the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------- |
+| message | string | Yes | String type.|
+
+**Error codes**
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+### setNumber10+
+
+setNumber(message: number): void
+
+Sets the number-type data of the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------- |
+| message | number | Yes | Data of the number type.|
+
+**Error codes**
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+### setBoolean10+
+
+setBoolean(message: boolean): void
+
+Sets the Boolean-type data for the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------- |
+| message | boolean | Yes | Data of the Boolean type.|
+
+**Error codes**
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+### setArrayBuffer10+
+
+setArrayBuffer(message: ArrayBuffer): void
+
+Sets the raw binary data for the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------- |
+| message | ArrayBuffer | Yes | Raw binary data.|
+
+**Error codes**
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+### setArray10+
+
+setArray(message: Array\): void
+
+Sets the array-type data for the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------- |
+| message | Array\ | Yes | Data of the array type.|
+
+**Error codes**
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+### setError10+
+
+setError(message: Error): void
+
+Sets the error-object-type data for the data object. For the complete sample code, see [onMessageEventExt](#onmessageeventext10).
+
+**System capability**: SystemCapability.Web.Webview.Core
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------- |
+| message | Error | Yes | Data of the error object type.|
+
+**Error codes**
+
+| ID| Error Message |
+| -------- | ------------------------------------- |
+| 17100014 | The type does not match with the value of the web message. |
+
+
## WebStorageOrigin
Provides usage information of the Web SQL Database.
diff --git a/en/application-dev/reference/errorcodes/errorcode-webview.md b/en/application-dev/reference/errorcodes/errorcode-webview.md
index d298583a7e63749b6ff5bdfe4548fe26422887e5..de75c73269bcad4b4777c237b729543bc871b24d 100644
--- a/en/application-dev/reference/errorcodes/errorcode-webview.md
+++ b/en/application-dev/reference/errorcodes/errorcode-webview.md
@@ -4,7 +4,6 @@
>
> This topic describes only module-specific error codes. For details about universal error codes, see [Universal Error Codes](errorcode-universal.md).
-
## 17100001 WebviewController Not Associated with a Web Component
**Error Message**
@@ -229,3 +228,41 @@ The related JS database API is not used.
1. Check whether the JS database API is used.
2. If the JS database API is used, find out the failure cause, for example, check whether **databaseAccess** is enabled.
+
+
+## 17100013 Memory Allocation Failure
+
+**Error Message**
+
+New failed, out of memeory.
+
+**Description**
+
+Memory allocation failed due to insufficient memory.
+
+**Possible Causes**
+
+The data to send is too large.
+
+**Solution**
+
+Check the length of the data to be sent.
+
+
+## 17100014 Type and Value Mismatch
+
+**Error Message**
+
+The type does not match with the value of the message.
+
+**Description**
+
+The type and value of the message do not match.
+
+**Possible Causes**
+
+The value of the obtained message does not match the type of the message.
+
+**Solution**
+
+Call the API based on the message type to obtain the message value. For example, if the type is **BOOLEAN**, call the **GetBoolean** API to obtain the Boolean value.
diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.6.1/changelog-web.md b/en/release-notes/changelogs/OpenHarmony_4.0.6.1/changelog-web.md
new file mode 100644
index 0000000000000000000000000000000000000000..a9ad760a1c58f12e013d2a7a9feeee6240cd37d2
--- /dev/null
+++ b/en/release-notes/changelogs/OpenHarmony_4.0.6.1/changelog-web.md
@@ -0,0 +1,33 @@
+# Web Subsystem Changelog
+
+Compared with earlier versions, OpenHarmony 4.0.6.1 has the following API changes in its web subsystem:
+
+## cl.web.1 Parameters in createWebMessagePorts
+
+Added an optional parameter to the **WebMessagePort** API to accommodate more data types.
+
+**Change Impact**
+
+None (The added parameter is optional, and the API is forward compatible.)
+
+**Key API/Component Changes**
+
+- Involved APIs:
+
+ createWebMessagePorts(): Array\;
+
+- Before change:
+
+ ```ts
+ createWebMessagePorts(): Array;
+ ```
+
+- After change:
+
+ ```ts
+ createWebMessagePorts(isExtentionType?: boolean): Array;
+ ```
+
+**Adaptation Guide**
+
+N/A