diff --git a/en/application-dev/notification/progress-bar-notification.md b/en/application-dev/notification/progress-bar-notification.md index de430008e3048532e9afea94d83a62dd2f8342c1..76e3292d79ae3a91a032ccf516c649ab39eda9e3 100644 --- a/en/application-dev/notification/progress-bar-notification.md +++ b/en/application-dev/notification/progress-bar-notification.md @@ -28,7 +28,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n ```ts notificationManager.isSupportTemplate('downloadTemplate').then((data) => { console.info(`[ANS] isSupportTemplate success`); - let isSupportTpl: boolean = data; // The value **true** means that the template of the **downloadTemplate** type is supported; and false means the opposite. + let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite. // ... }).catch((err) => { console.error(`[ANS] isSupportTemplate failed, error[${err}]`); diff --git a/en/application-dev/reference/apis/js-apis-webview.md b/en/application-dev/reference/apis/js-apis-webview.md index ba1368a1812949b00d7aa2a04846fb812aa49c82..e714785f8e4af50f04a206e2fc2fd67e9c55044b 100644 --- a/en/application-dev/reference/apis/js-apis-webview.md +++ b/en/application-dev/reference/apis/js-apis-webview.md @@ -2,7 +2,7 @@ # @ohos.web.webview (Webview) -The **Webview** module provides APIs for web control. +The **Webview** module provides APIs for web control. It can be used with the **[](../arkui-ts/ts-basic-components-web.md)** component, which can be used to display web pages. > **NOTE** > @@ -20,7 +20,7 @@ The **Webview** module provides APIs for web control. import web_webview from '@ohos.web.webview'; ``` -### once +## once once(type: string, callback: Callback\): void @@ -43,7 +43,7 @@ import web_webview from '@ohos.web.webview' web_webview.once("webInited", () => { console.log("setCookie") - web_webview.WebCookieManager.setCookie("www.example.com", "a=b") + web_webview.WebCookieManager.setCookie("https://www.example.com", "a=b") }) @Entry @@ -338,7 +338,6 @@ struct WebComponent { } }) Web({ src: 'www.example.com', controller: this.controller }) - .webDebuggingAccess(true) } } } @@ -438,7 +437,34 @@ struct WebComponent { } ``` -### accessforward +Example of loading local resource: +```ts +// xxx.ets +import web_webview from '@ohos.web.webview' + +@Entry +@Component +struct WebComponent { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + updataContent: string = '
image -- end
' + + build() { + Column() { + Button('loadData') + .onClick(() => { + try { + this.controller.loadData(this.updataContent, "text/html", "UTF-8", " ", " "); + } catch (error) { + console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); + } + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } +} +``` + +### accessForward accessForward(): boolean @@ -854,7 +880,7 @@ struct WebComponent { ### getHitTest -getHitTest(): HitTestTypeV9 +getHitTest(): WebHitTestType Obtains the element type of the area being clicked. @@ -1565,7 +1591,7 @@ struct WebComponent { .onClick(() => { try { if (this.ports && this.ports[1]) { - this.ports[1].postMessageEvent("post message from ets to HTML"); + this.ports[1].postMessageEvent(this.sendFromEts); } else { console.error(`ports is null, Please initialize first`); } @@ -3174,7 +3200,7 @@ struct WebComponent { Button('getCookie') .onClick(() => { try { - let value = web_webview.WebCookieManager.getCookie('www.example.com'); + let value = web_webview.WebCookieManager.getCookie('https://www.example.com'); console.log("value: " + value); } catch (error) { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); @@ -3226,7 +3252,7 @@ struct WebComponent { Button('setCookie') .onClick(() => { try { - web_webview.WebCookieManager.setCookie('www.example.com', 'a=b'); + web_webview.WebCookieManager.setCookie('https://www.example.com', 'a=b'); } catch (error) { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } @@ -3604,7 +3630,7 @@ Deletes all data in the specified origin. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------ | -| origin | string | Yes | Index of the origin.| +| origin | string | Yes | Index of the origin, which is obtained through [getOrigins](#getorigins). | **Error codes** @@ -4094,9 +4120,6 @@ struct WebComponent { try { this.username_password = web_webview.WebDataBase.getHttpAuthCredentials(this.host, this.realm); console.log('num: ' + this.username_password.length); - ForEach(this.username_password, (item) => { - console.log('username_password: ' + item); - }, item => item) } catch (error) { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md index c6244ab23656e0dba7011aae7a19a88d577d7afd..b35ea95d9dc2ae371e0cf65da37ee6cb5a873689 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -1,6 +1,6 @@ # Web -The **** component can be used to display web pages. +The **** 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. > **NOTE** > @@ -16,7 +16,7 @@ Not supported ## APIs -Web(options: { src: ResourceStr, controller: WebController | WebviewController}) +Web(options: { src: ResourceStr, controller: WebviewController | WebController}) > **NOTE** > @@ -28,26 +28,13 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController}) | Name | Type | Mandatory | Description | | ---------- | ---------------------------------------- | ---- | ------- | | src | [ResourceStr](ts-types.md) | Yes | Address of a web page resource.| -| controller | [WebController](#webcontroller) \| [WebviewController9+](../apis/js-apis-webview.md#webviewcontroller) | Yes | Controller. | +| controller | [WebviewController9+](../apis/js-apis-webview.md#webviewcontroller) \| [WebController](#webcontroller) | Yes | Controller. **WebController** is deprecated since API version 9. You are advised to use **WebviewController** instead.| **Example** Example of loading online web pages: ```ts // xxx.ets - @Entry - @Component - struct WebComponent { - controller: WebController = new WebController() - build() { - Column() { - Web({ src: 'www.example.com', controller: this.controller }) - } - } - } - ``` - ```ts - // xxx.ets import web_webview from '@ohos.web.webview' @Entry @@ -68,7 +55,7 @@ Web(options: { src: ResourceStr, controller: WebController | WebviewController}) @Entry @Component struct WebComponent { - controller: WebController = new WebController() + controller: web_webview.WebviewController = new web_webview.WebviewController() build() { Column() { Web({ src: $rawfile("index.html"), controller: this.controller }) @@ -4965,7 +4952,7 @@ Sets the cookie. This API returns the result synchronously. Returns **true** if Column() { Button('setCookie') .onClick(() => { - let result = this.controller.getCookieManager().setCookie("www.example.com", "a=b") + let result = this.controller.getCookieManager().setCookie("https://www.example.com", "a=b") console.log("result: " + result) }) Web({ src: 'www.example.com', controller: this.controller })