PermissionStatus: name プロパティ
Baseline 2022Newly available
Since September 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
メモ: この機能はウェブワーカー内で利用可能です。
name
は PermissionStatus
インターフェイスの読み取り専用プロパティで、要求された権限の名前を返します。
値
読み取り専用で、navigator.permissions.query()
に渡された name
引数と同じ値です。
例
js
function stateChangeListener() {
console.log(`${this.name} の権限の状態は ${this.state} に変化しました。`);
}
function queryAndTrackPermission(permissionName) {
navigator.permissions
.query({ name: permissionName })
.then((permissionStatus) => {
console.log(
`${permissionName} の権限の状態は ${permissionStatus.state} です。`,
);
permissionStatus.onchange = stateChangeListener;
});
}
queryAndTrackPermission("geolocation");
queryAndTrackPermission("midi");
仕様書
Specification |
---|
Permissions # dom-permissionstatus-name |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.