From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/document/hasstorageaccess/index.html | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 files/zh-cn/web/api/document/hasstorageaccess/index.html (limited to 'files/zh-cn/web/api/document/hasstorageaccess') diff --git a/files/zh-cn/web/api/document/hasstorageaccess/index.html b/files/zh-cn/web/api/document/hasstorageaccess/index.html new file mode 100644 index 0000000000..b0f07d0bf8 --- /dev/null +++ b/files/zh-cn/web/api/document/hasstorageaccess/index.html @@ -0,0 +1,49 @@ +--- +title: Document.hasStorageAccess() +slug: Web/API/Document/hasStorageAccess +translation_of: Web/API/Document/hasStorageAccess +--- +
{{APIRef}}{{seecompattable}}
+ +
{{domxref("Document")}}的hasStorageAccess() 方法返回了一个{{jsxref("Promise")}}来判断该文档是否有访问第一方储存的权限。
+ +

通过 Storage Access API 获取更多信息。

+ +

语法

+ +
var promise = document.hasStorageAccess();
+ +

参数

+ +

None.

+ +

返回值

+ +

一个用来判断文档是否有权利访问其第一方存储的{{jsxref("Promise")}} 。

+ +

If the promise gets resolved and a user gesture event was being processed when the function was originally called, the resolve handler will run as if a user gesture was being processed, so it will be able to call APIs that require user activation.

+ +

Examples

+ +
document.hasStorageAccess().then(hasAccess => {
+  if (hasAccess) {
+    // storage access has been granted already.
+  } else {
+    // storage access hasn't been granted already;
+    // you may want to call requestStorageAccess().
+  }
+});
+ +

Specifications

+ +

The API is currently only at the proposal stage — the standardization process has yet to begin. You can currently find specification details of the API at Apple's Introducing Storage Access API blog post, and WHATWG HTML issue 3338 — Proposal: Storage Access API.

+ +

Browser compatibility

+ + + +

{{Compat("api.Document.hasStorageAccess")}}

+ +

See also

+ +

Storage Access API

-- cgit v1.2.3-54-g00ecf