--- title: Document.hasStorageAccess() slug: Web/API/Document/hasStorageAccess translation_of: Web/API/Document/hasStorageAccess ---
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.
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(). } });
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.
{{Compat("api.Document.hasStorageAccess")}}