Document: hasUnpartitionedCookieAccess() メソッド

Limited availability

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

hasUnpartitionedCookieAccess()Document インターフェイスのメソッドで、論理値を返すプロミス (Promise) を返します。これはこの文書がサードパーティ分離されていないクッキーへのアクセス権があるかどうかを示します。

このメソッドはストレージアクセス API の一部です。

このメソッドは Document.hasStorageAccess() の新しい名前です。

構文

js
hasUnpartitionedCookieAccess()

引数

なし。

返値

文書がサードパーティクッキーにアクセスできるかどうかを示す論理値で解決する Promise です。サードパーティクッキーにアクセスできる場合は true、できない場合は false です。

詳しくは Document.hasStorageAccess() を参照してください。

例外

InvalidStateError DOMException

現在の Document がまだアクティブでない場合に発生します。

js
document.hasUnpartitionedCookieAccess().then((hasAccess) => {
  if (hasAccess) {
    // ストレージへのアクセスはすでに許可されています。
    console.log("クッキーへのアクセスが許可されました");
  } else {
    // ストレージへのアクセスはまだ許可されていません。
    // requestStorageAccess() を呼び出す必要があります。
    console.log("クッキーへのアクセスが拒否されました");
  }
});

メモ: より完全な例は、ストレージアクセス API の使用を参照してください。

仕様書

Specification
Extending Storage Access API (SAA) to non-cookie storage
# dom-document-hasunpartitionedcookieaccess

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
hasUnpartitionedCookieAccess

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

関連情報