Back to Content

StorageAccessHandle: SharedWorker() method

files/en-us/web/api/storageaccesshandle/sharedworker/index.md

latest1.4 KB
Original Source

{{APIRef("Storage Access API")}}

[!NOTE] See {{domxref("SharedWorker.SharedWorker", "SharedWorker()")}} to understand usage.

Syntax

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

Parameters

  • url
    • : See {{domxref("SharedWorker.SharedWorker", "SharedWorker()")}}.
  • name {{optional_inline}}
    • : See {{domxref("SharedWorker.SharedWorker", "SharedWorker()")}}.
  • options {{optional_inline}}
    • : See {{domxref("SharedWorker.SharedWorker", "SharedWorker()")}}.

[!NOTE] options.sameSiteCookies only supports the value "none", which is the default.

Return value

An unpartitioned {{domxref("SharedWorker")}} object.

Exceptions

  • SecurityError {{domxref("DomException")}}
    • : Thrown if access was not granted.

See {{domxref("SharedWorker.SharedWorker", "SharedWorker()")}}

Examples

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

[!NOTE] See Using the Storage Access API for a more complete example.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also