StorageAccessHandle: phương thức SharedWorker()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Note: Xem SharedWorker() để hiểu cách sử dụng.

Cú pháp

js
SharedWorker(url)
SharedWorker(url, name)
SharedWorker(url, options)

Tham số

url

Xem SharedWorker().

name Optional

Xem SharedWorker().

options Optional

Xem SharedWorker().

Note: options.sameSiteCookies chỉ hỗ trợ giá trị "none", đây là giá trị mặc định.

Giá trị trả về

Một đối tượng SharedWorker không phân vùng.

Ngoại lệ

SecurityError DomException

Được ném ra nếu quyền truy cập không được cấp.

Xem SharedWorker()

Ví dụ

js
document.requestStorageAccess({ SharedWorker: true }).then(
  (handle) => {
    console.log("SharedWorker access granted");
    handle.SharedWorker(shared_worker_url);
  },
  () => {
    console.log("SharedWorker access denied");
  },
);

Note: Xem Using the Storage Access API để biết ví dụ đầy đủ hơn.

Thông số kỹ thuật

Specification
Extending Storage Access API (SAA) to non-cookie storage
# dom-storageaccesshandle-sharedworker

Tương thích trình duyệt

Xem thêm