PermissionStatus

Baseline 2022
Newly available

Since September 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

メモ: この機能はウェブワーカー内で利用可能です。

PermissionStatus権限 API のインターフェイスで、オブジェクトの状態と、その状態の変化を監視するためのイベントハンドラーを提供します。

EventTarget PermissionStatus

インスタンスプロパティ

PermissionStatus.name 読取専用

要求された権限の名前を返します。Permissions.query に渡された name と同じです。

PermissionStatus.state 読取専用

要求された権限の状態を返します。 'granted'(許可)、'denied'(拒否)、'prompt'(プロンプト)のいずれかです。

イベントハンドラー

change

PermissionStatus.state 変化するたびに発行されるイベントです。

js
navigator.permissions
  .query({ name: "geolocation" })
  .then((permissionStatus) => {
    console.log(`位置情報の権限の状態は ${permissionStatus.state} です。`);
    permissionStatus.onchange = () => {
      console.log(
        `位置情報の権限の状態が ${permissionStatus.state} に変更されました。`,
      );
    };
  });

仕様書

Specification
Permissions
# permissionstatus-interface

ブラウザーの互換性

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
PermissionStatus
change event
name
state

Legend

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

Full support
Full support
No support
No support
See implementation notes.
Uses a non-standard name.
Has more compatibility info.