diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md
index 15da71fb6dd4c6921ab40415a5ce3e213bdd05d1..2c20196bac9c25344ed27fb3957b24d011daca9d 100644
--- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md
+++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md
@@ -1761,7 +1761,7 @@ onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean
}
```
-### onRenderExited
+### onRenderExited9+
onRenderExited(callback: (event?: { renderExitReason: RenderExitReason }) => void)
@@ -3537,24 +3537,28 @@ invoke(origin: string, allow: boolean, retain: boolean): void
| ------ | ------- | ---- | ---- | ---------------------------------------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
| allow | boolean | 是 | - | 设置的地理位置权限状态。 |
-| retain | boolean | 是 | - | 是否允许将地理位置权限状态保存到系统中。可通过[GeolocationPermissions](#geolocationpermissions9)接口管理保存到系统的地理位置权限。 |
+| retain | boolean | 是 | - | 是否允许将地理位置权限状态保存到系统中。可通过[GeolocationPermissions9+](../apis/js-apis-webview.md#geolocationpermissions)接口管理保存到系统的地理位置权限。 |
## WebController
通过WebController可以控制Web组件各种行为。一个WebController对象只能控制一个Web组件,且必须在Web组件和WebController绑定后,才能调用WebController上的方法。
+从API version 9开始不再维护,建议使用[WebviewController9+](../apis/js-apis-webview.md#webviewcontroller)代替。
+
### 创建对象
```
webController: WebController = new WebController()
```
-### requestFocus
+### requestFocus(deprecated)
requestFocus()
使当前web页面获取焦点。
+从API version 9开始不再维护,建议使用[requestFocus9+](../apis/js-apis-webview.md#requestfocus)代替。
+
**示例:**
```ts
@@ -3576,12 +3580,14 @@ requestFocus()
}
```
-### accessBackward
+### accessBackward(deprecated)
accessBackward(): boolean
当前页面是否可后退,即当前页面是否有返回历史记录。
+从API version 9开始不再维护,建议使用[accessBackward9+](../apis/js-apis-webview.md#accessbackward)代替。
+
**返回值:**
| 类型 | 说明 |
@@ -3610,12 +3616,14 @@ accessBackward(): boolean
}
```
-### accessForward
+### accessForward(deprecated)
accessForward(): boolean
当前页面是否可前进,即当前页面是否有前进历史记录。
+从API version 9开始不再维护,建议使用[accessForward9+](../apis/js-apis-webview.md#accessforward)代替。
+
**返回值:**
| 类型 | 说明 |
@@ -3644,12 +3652,14 @@ accessForward(): boolean
}
```
-### accessStep
+### accessStep(deprecated)
accessStep(step: number): boolean
当前页面是否可前进或者后退给定的step步。
+从API version 9开始不再维护,建议使用[accessStep9+](../apis/js-apis-webview.md#accessstep)代替。
+
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
@@ -3685,12 +3695,14 @@ accessStep(step: number): boolean
}
```
-### backward
+### backward(deprecated)
backward(): void
按照历史栈,后退一个页面。一般结合accessBackward一起使用。
+从API version 9开始不再维护,建议使用[backward9+](../apis/js-apis-webview.md#backward)代替。
+
**示例:**
```ts
@@ -3712,12 +3724,14 @@ backward(): void
}
```
-### forward
+### forward(deprecated)
forward(): void
按照历史栈,前进一个页面。一般结合accessForward一起使用。
+从API version 9开始不再维护,建议使用[forward9+](../apis/js-apis-webview.md#forward)代替。
+
**示例:**
```ts
@@ -3773,12 +3787,14 @@ backOrForward(step: number): void
}
```
-### deleteJavaScriptRegister
+### deleteJavaScriptRegister(deprecated)
deleteJavaScriptRegister(name: string)
删除通过registerJavaScriptProxy注册到window上的指定name的应用侧JavaScript对象。删除后立即生效,无须调用[refresh](#refresh)接口。
+从API version 9开始不再维护,建议使用[deleteJavaScriptRegister9+](../apis/js-apis-webview.md#deletejavascriptregister)代替。
+
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
@@ -3807,12 +3823,14 @@ deleteJavaScriptRegister(name: string)
}
```
-### getHitTest
+### getHitTest(deprecated)
getHitTest(): HitTestType
获取当前被点击区域的元素类型。
+从API version 9开始不再维护,建议使用[getHitTest9+](../apis/js-apis-webview.md#gethittest)代替。
+
**返回值:**
| 类型 | 说明 |
@@ -4007,7 +4025,7 @@ getDefaultUserAgent(): string
}
```
-### loadData
+### loadData(deprecated)
loadData(options: { data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string })
@@ -4017,6 +4035,8 @@ baseUrl为空时,通过”data“协议加载指定的一段字符串。
当baseUrl为“http/https"协议时,编码后的data字符串将被Web组件以类似loadUrl的方式以非编码字符串处理。
+从API version 9开始不再维护,建议使用[loadData9+](../apis/js-apis-webview.md#loaddata)代替。
+
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
@@ -4052,7 +4072,7 @@ baseUrl为空时,通过”data“协议加载指定的一段字符串。
}
```
-### loadUrl
+### loadUrl(deprecated)
loadUrl(options: { url: string | Resource, headers?: Array\ })
@@ -4062,6 +4082,8 @@ loadUrl(options: { url: string | Resource, headers?: Array\ })
而通过registerJavaScriptProxy注入的对象,在loadUrl导航到新的页面也会有效。
+从API version 9开始不再维护,建议使用[loadUrl9+](../apis/js-apis-webview.md#loadurl)代替。
+
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
@@ -4090,12 +4112,14 @@ loadUrl(options: { url: string | Resource, headers?: Array\ })
}
```
-### onActive
+### onActive(deprecated)
onActive(): void
调用此接口通知Web组件进入前台激活状态。
+从API version 9开始不再维护,建议使用[onActive9+](../apis/js-apis-webview.md#onactive)代替。
+
**示例:**
```ts
@@ -4117,12 +4141,14 @@ onActive(): void
}
```
-### onInactive
+### onInactive(deprecated)
onInactive(): void
调用此接口通知Web组件进入未激活状态。
+从API version 9开始不再维护,建议使用[onInactive9+](../apis/js-apis-webview.md#oninactive)代替。
+
**示例:**
```ts
@@ -4144,11 +4170,13 @@ onInactive(): void
}
```
-### zoom
+### zoom(deprecated)
zoom(factor: number): void
调整当前网页的缩放比例。
+从API version 9开始不再维护,建议使用[zoom9+](../apis/js-apis-webview.md#zoom)代替。
+
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
@@ -4243,12 +4271,14 @@ zoomOut(): boolean
}
```
-### refresh
+### refresh(deprecated)
refresh()
调用此接口通知Web组件刷新网页。
+从API version 9开始不再维护,建议使用[refresh9+](../apis/js-apis-webview.md#refresh)代替。
+
**示例:**
```ts
@@ -4270,12 +4300,14 @@ refresh()
}
```
-### registerJavaScriptProxy
+### registerJavaScriptProxy(deprecated)
registerJavaScriptProxy(options: { object: object, name: string, methodList: Array\ })
注入JavaScript对象到window对象中,并在window对象中调用该对象的方法。注册后,须调用[refresh](#refresh)接口生效。
+从API version 9开始不再维护,建议使用[registerJavaScriptProxy9+](../apis/js-apis-webview.md#registerjavascriptproxy)代替。
+
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
@@ -4336,12 +4368,14 @@ registerJavaScriptProxy(options: { object: object, name: string, methodList: Arr
```
-### runJavaScript
+### runJavaScript(deprecated)
runJavaScript(options: { script: string, callback?: (result: string) => void })
异步执行JavaScript脚本,并通过回调方式返回脚本执行的结果。runJavaScript需要在loadUrl完成后,比如onPageEnd中调用。
+从API version 9开始不再维护,建议使用[runJavaScript9+](../apis/js-apis-webview.md#runjavascript)代替。
+
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
@@ -4395,12 +4429,14 @@ runJavaScript(options: { script: string, callback?: (result: string) => void })
```
-### stop
+### stop(deprecated)
stop()
停止页面加载。
+从API version 9开始不再维护,建议使用[stop9+](../apis/js-apis-webview.md#stop)代替。
+
**示例:**
```ts
@@ -4422,12 +4458,14 @@ stop()
}
```
-### clearHistory
+### clearHistory(deprecated)
clearHistory(): void
删除所有前进后退记录。
+从API version 9开始不再维护,建议使用[clearHistory9+](../apis/js-apis-webview.md#clearhistory)代替。
+
**示例:**
```ts
@@ -4891,39 +4929,6 @@ setCookie(url: string, value: string): boolean
}
```
-### saveCookieSync9+
-saveCookieSync(): boolean
-
-将当前存在内存中的cookie同步到磁盘中,该方法为同步方法。
-
-**返回值:**
-
-| 类型 | 说明 |
-| ------- | -------------------- |
-| boolean | 同步内存cookie到磁盘操作是否成功。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
-
- build() {
- Column() {
- Button('saveCookieSync')
- .onClick(() => {
- let result = this.controller.getCookieManager().saveCookieSync()
- console.log("result: " + result)
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
### getCookie9+
getCookie(url: string): string
@@ -5335,762 +5340,6 @@ deleteSessionCookie(): void
}
```
-## WebDataBase9+
-web组件数据库管理对象。
-
-### existHttpAuthCredentials9+
-
-static existHttpAuthCredentials(): boolean
-
-判断是否存在任何已保存的HTTP身份验证凭据,该方法为同步方法。存在返回true,不存在返回false。
-
-**返回值:**
-
-| 类型 | 说明 |
-| ------- | ---------------------------------------- |
-| boolean | 是否存在任何已保存的HTTP身份验证凭据。存在返回true,不存在返回false |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
-
- build() {
- Column() {
- Button('existHttpAuthCredentials')
- .onClick(() => {
- let result = web_webview.WebDataBase.existHttpAuthCredentials()
- console.log('result: ' + result)
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### deleteHttpAuthCredentials9+
-
-static deleteHttpAuthCredentials(): void
-
-清除所有已保存的HTTP身份验证凭据,该方法为同步方法。
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
-
- build() {
- Column() {
- Button('deleteHttpAuthCredentials')
- .onClick(() => {
- web_webview.WebDataBase.deleteHttpAuthCredentials()
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### getHttpAuthCredentials9+
-
-static getHttpAuthCredentials(host: string, realm: string): Array\
-
-检索给定主机和域的HTTP身份验证凭据,该方法为同步方法。检索成功返回一个包含用户名和密码的组数,检索不成功返回空数组。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
-| ----- | ------ | ---- | ---- | ---------------- |
-| host | string | 是 | - | HTTP身份验证凭据应用的主机。 |
-| realm | string | 是 | - | HTTP身份验证凭据应用的域。 |
-
-**返回值:**
-
-| 类型 | 说明 |
-| --------------- | ---------------------- |
-| Array\ | 包含用户名和密码的组数,检索失败返回空数组。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- host: string = "www.spincast.org"
- realm: string = "protected example"
- username_password: string[]
- build() {
- Column() {
- Button('getHttpAuthCredentials')
- .onClick(() => {
- 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)
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### saveHttpAuthCredentials9+
-
-static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void
-
-保存给定主机和域的HTTP身份验证凭据,该方法为同步方法。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
-| -------- | ------ | ---- | ---- | ---------------- |
-| host | string | 是 | - | HTTP身份验证凭据应用的主机。 |
-| realm | string | 是 | - | HTTP身份验证凭据应用的域。 |
-| username | string | 是 | - | 用户名。 |
-| password | string | 是 | - | 密码。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- host: string = "www.spincast.org"
- realm: string = "protected example"
- build() {
- Column() {
- Button('saveHttpAuthCredentials')
- .onClick(() => {
- web_webview.WebDataBase.saveHttpAuthCredentials(this.host, this.realm, "Stromgol", "Laroche")
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-## GeolocationPermissions9+
-
-web组件地理位置权限管理对象。
-
-### allowGeolocation9+
-
-static allowGeolocation(origin: string): void
-
-允许指定来源使用地理位置接口。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
-| ------ | ------ | ---- | ---- | ---------- |
-| origin | string | 是 | - | 指定源的字符串索引。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- origin: string = "file:///"
- build() {
- Column() {
- Button('allowGeolocation')
- .onClick(() => {
- web_webview.GeolocationPermissions.allowGeolocation(this.origin)
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### deleteGeolocation9+
-
-static deleteGeolocation(origin: string): void
-
-清除指定来源的地理位置权限状态。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
-| ------ | ------ | ---- | ---- | ---------- |
-| origin | string | 是 | - | 指定源的字符串索引。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- origin: string = "file:///"
- build() {
- Column() {
- Button('deleteGeolocation')
- .onClick(() => {
- web_webview.GeolocationPermissions.deleteGeolocation(this.origin)
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### deleteAllGeolocation9+
-
-static deleteAllGeolocation(): void
-
-清除所有来源的地理位置权限状态。
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- build() {
- Column() {
- Button('deleteAllGeolocation')
- .onClick(() => {
- web_webview.GeolocationPermissions.deleteAllGeolocation()
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### getAccessibleGeolocation9+
-
-static getAccessibleGeolocation(origin: string, callback: AsyncCallback\): void
-
-以回调方式异步获取指定源的地理位置权限状态。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
-| -------- | ------------------------ | ---- | ---- | ---------------------------------------- |
-| origin | string | 是 | - | 指定源的字符串索引。 |
-| callback | AsyncCallback\ | 是 | - | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- origin: string = "file:///"
- build() {
- Column() {
- Button('getAccessibleGeolocationAsync')
- .onClick(() => {
- web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
- if (error) {
- console.log('getAccessibleGeolocationAsync error: ' + JSON.stringify(error))
- return
- }
- console.log('getAccessibleGeolocationAsync result: ' + result)
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### getAccessibleGeolocation9+
-
-static getAccessibleGeolocation(origin: string): Promise\
-
-以Promise方式异步获取指定源的地理位置权限状态。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
-| ------ | ------ | ---- | ---- | ---------- |
-| origin | string | 是 | - | 指定源的字符串索引。 |
-
-**返回值:**
-
-| 类型 | 说明 |
-| ------------------ | ---------------------------------------- |
-| Promise\ | Promise实例,用于获取指定源的权限状态,获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- origin: string = "file:///"
- build() {
- Column() {
- Button('getAccessibleGeolocationPromise')
- .onClick(() => {
- web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin).then(result => {
- console.log('getAccessibleGeolocationPromise result: ' + result)
- }).catch(error => {
- console.log('getAccessibleGeolocationPromise error: ' + JSON.stringify(error))
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### getStoredGeolocation9+
-
-static getStoredGeolocation(callback: AsyncCallback\\>): void
-
-以回调方式异步获取已存储地理位置权限状态的所有源信息。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
-| -------- | -------------------------------- | ---- | ---- | -------------------- |
-| callback | AsyncCallback\\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- build() {
- Column() {
- Button('getStoredGeolocationAsync')
- .onClick(() => {
- web_webview.GeolocationPermissions.getStoredGeolocation((error, origins) => {
- if (error) {
- console.log('getStoredGeolocationAsync error: ' + JSON.stringify(error))
- return
- }
- let origins_str: string = origins.join()
- console.log('getStoredGeolocationAsync origins: ' + origins_str)
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-### getStoredGeolocation9+
-
-static getStoredGeolocation(): Promise\\>
-
-以Promise方式异步获取已存储地理位置权限状态的所有源信息。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
-| -------- | -------------------------------- | ---- | ---- | -------------------- |
-| callback | AsyncCallback\\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 |
-
-**返回值:**
-
-| 类型 | 说明 |
-| -------------------------- | -------------------------------- |
-| Promise\\> | Promise实例,用于获取已存储地理位置权限状态的所有源信息。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- build() {
- Column() {
- Button('getStoredGeolocationPromise')
- .onClick(() => {
- web_webview.GeolocationPermissions.getStoredGeolocation().then(origins => {
- let origins_str: string = origins.join()
- console.log('getStoredGeolocationPromise origins: ' + origins_str)
- }).catch(error => {
- console.log('getStoredGeolocationPromise error: ' + JSON.stringify(error))
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- }
- }
- }
- ```
-
-## WebStorage9+
-通过WebStorage可管理Web SQL数据库接口和HTML5 Web存储接口,每个应用中的所有Web组件共享一个WebStorage。
-### deleteAllData9+
-static deleteAllData(): void
-
-清除Web SQL数据库当前使用的所有存储。
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- build() {
- Column() {
- Button('deleteAllData')
- .onClick(() => {
- web_webview.WebStorage.deleteAllData()
- })
- Web({ src: 'www.example.com', controller: this.controller })
- .databaseAccess(true)
- }
- }
- }
- ```
-
-### deleteOrigin9+
-static deleteOrigin(origin : string): void
-
-清除指定源所使用的存储。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 说明 |
-| ------ | ------ | ---- | ---------- |
-| origin | string | 是 | 指定源的字符串索引。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- origin: string = "origin"
- build() {
- Column() {
- Button('getHttpAuthCredentials')
- .onClick(() => {
- web_webview.WebStorage.deleteOrigin(this.origin)
- })
- Web({ src: 'www.example.com', controller: this.controller })
- .databaseAccess(true)
- }
- }
- }
- ```
-
-### getOrigins9+
-static getOrigins(callback: AsyncCallback\>) : void
-
-以回调方式异步获取当前使用Web SQL数据库的所有源的信息。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 说明 |
-| -------- | ---------------------------------------- | ---- | ----------------------------------- |
-| callback | AsyncCallback> | 是 | 以数组方式返回源的信息,信息内容参考WebStorageOrigin。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- origin: string = "origin"
- build() {
- Column() {
- Button('getOrigins')
- .onClick(() => {
- web_webview.WebStorage.getOrigins((error, origins) => {
- if (error) {
- console.log('error: ' + error)
- return
- }
- for (let i = 0; i < origins.length; i++) {
- console.log('origin: ' + origins[i].origin)
- console.log('usage: ' + origins[i].usage)
- console.log('quota: ' + origins[i].quota)
- }
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- .databaseAccess(true)
- }
- }
- }
- ```
-
-### getOrigins9+
-static getOrigins() : Promise\>
-
-以Promise方式异步获取当前使用Web SQL数据库的所有源的信息。
-
-**返回值:**
-
-| 类型 | 说明 |
-| ---------------------------------------- | ---------------------------------------- |
-| Promise> | Promise实例,用于获取当前所有源的信息,信息内容参考WebStorageOrigin。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- origin: string = "origin"
- build() {
- Column() {
- Button('getOrigins')
- .onClick(() => {
- web_webview.WebStorage.getOrigins()
- .then(origins => {
- for (let i = 0; i < origins.length; i++) {
- console.log('origin: ' + origins[i].origin)
- console.log('usage: ' + origins[i].usage)
- console.log('quota: ' + origins[i].quota)
- }
- })
- .catch(error => {
- console.log('error: ' + error)
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- .databaseAccess(true)
- }
- }
- }
- ```
-
-### getOriginQuota9+
-static getOriginQuota(origin : string, callback : AsyncCallback\) : void
-
-使用callback回调异步获取指定源的Web SQL数据库的存储配额,配额以字节为单位。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 说明 |
-| -------- | ---------------------- | ---- | --------- |
-| origin | string | 是 | 指定源的字符串索引 |
-| callback | AsyncCallback\ | 是 | 指定源的存储配额。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController()
- origin: string = "origin"
- build() {
- Column() {
- Button('getOriginQuota')
- .onClick(() => {
- web_webview.WebStorage.getOriginQuota(this.origin, (error, quota) => {
- if (error) {
- console.log('error: ' + error)
- return
- }
- console.log('quota: ' + quota)
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- .databaseAccess(true)
- }
- }
- }
- ```
-
-### getOriginQuota9+
-static getOriginQuota(origin : string) : Promise\
-
-以Promise方式异步获取指定源的Web SQL数据库的存储配额,配额以字节为单位。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 说明 |
-| ------ | ------ | ---- | ---------- |
-| origin | string | 是 | 指定源的字符串索引。 |
-
-**返回值:**
-
-| 类型 | 说明 |
-| ---------------- | ----------------------- |
-| Promise\ | Promise实例,用于获取指定源的存储配额。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController();
- origin: string = "origin"
- build() {
- Column() {
- Button('getOriginQuota')
- .onClick(() => {
- web_webview.WebStorage.getOriginQuota(this.origin)
- .then(quota => {
- console.log('quota: ' + quota)
- })
- .catch(error => {
- console.log('error: ' + error)
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- .databaseAccess(true)
- }
- }
- }
- ```
-
-### getOriginUsage9+
-static getOriginUsage(origin : string, callback : AsyncCallback\) : void
-
-以回调方式异步获取指定源的Web SQL数据库的存储量,存储量以字节为单位。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 说明 |
-| -------- | ---------------------- | ---- | ---------- |
-| origin | string | 是 | 指定源的字符串索引。 |
-| callback | AsyncCallback\ | 是 | 指定源的存储量。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController();
- origin: string = "origin"
- build() {
- Column() {
- Button('getOriginUsage')
- .onClick(() => {
- web_webview.WebStorage.getOriginUsage(this.origin, (error, usage) => {
- if (error) {
- console.log('error: ' + error)
- return
- }
- console.log('usage: ' + usage)
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- .databaseAccess(true)
- }
- }
- }
- ```
-
-### getOriginUsage9+
-static getOriginUsage(origin : string) : Promise\
-
-以Promise方式异步获取指定源的Web SQL数据库的存储量,存储量以字节为单位。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 说明 |
-| ------ | ------ | ---- | ---------- |
-| origin | string | 是 | 指定源的字符串索引。 |
-
-**返回值:**
-
-| 类型 | 说明 |
-| ---------------- | ---------------------- |
-| Promise\ | Promise实例,用于获取指定源的存储量。 |
-
-**示例:**
-
- ```ts
- // xxx.ets
- import web_webview from '@ohos.web.webview'
- @Entry
- @Component
- struct WebComponent {
- controller: WebController = new WebController();
- origin: string = "origin"
- build() {
- Column() {
- Button('getOriginQuota')
- .onClick(() => {
- web_webview.WebStorage.getOriginUsage(this.origin)
- .then(usage => {
- console.log('usage: ' + usage)
- })
- .catch(error => {
- console.log('error: ' + error)
- })
- })
- Web({ src: 'www.example.com', controller: this.controller })
- .databaseAccess(true)
- }
- }
- }
- ```
-
-## WebStorageOrigin9+
-
-提供Web SQL数据库的使用信息。
-
-**参数:**
-
-| 参数名 | 参数类型 | 必填 | 说明 |
-| ------ | ------ | ---- | ---------- |
-| origin | string | 是 | 指定源的字符串索引。 |
-| usage | number | 是 | 指定源的存储量。 |
-| quota | number | 是 | 指定源的存储配额。 |
-
## MessageLevel枚举说明
| 名称 | 描述 |