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

Limited availability

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

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

Cú pháp

js
BroadcastChannel(channelName)

Tham số

channelName

Xem BroadcastChannel().

Giá trị trả về

Một đối tượng BroadcastChannel 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 BroadcastChannel()

Ví dụ

js
document.requestStorageAccess({ BroadcastChannel: true }).then(
  (handle) => {
    console.log("BroadcastChannel access granted");
    handle.BroadcastChannel(channel_name);
  },
  () => {
    console.log("BroadcastChannel 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-broadcastchannel

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

Xem thêm