StorageAccessHandle: thuộc tính localStorage
Khả dụng hạn chế
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Thuộc tính localStorage của giao diện StorageAccessHandle trả về một đối tượng Storage cục bộ không phân vùng nếu quyền truy cập được cấp, và ném ra SecurityError DOMException trong trường hợp khác.
Giá trị
Một đối tượng Storage.
Ví dụ
js
document.requestStorageAccess({ localStorage: true }).then(
(handle) => {
console.log("localStorage access granted");
handle.localStorage.setItem("foo", "bar");
},
() => {
console.log("localStorage access denied");
},
);
Note: Xem Using the Storage Access API để biết ví dụ đầy đủ hơn.
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Extending Storage Access API (SAA) to non-cookie storage> # dom-storageaccesshandle-localstorage> |