The PermissionStatus
interface of the Permissions API provides the state of an object and an event handler for monitoring changes to said state.
The PermissionStatus
interface of the Permissions API provides the state of an object and an event handler for monitoring changes to said state.
PermissionStatus.name
Read only
Returns the name of a requested permission, identical to the name
passed to Permissions.query
.
PermissionStatus.state
Read only
Returns the state of a requested permission; one of 'granted'
, 'denied'
, or 'prompt'
.
PermissionStatus.status
Read only Deprecated
Returns the state of a requested permission; one of 'granted'
, 'denied'
, or 'prompt'
. Later versions of the specification replace this with PermissionStatus.state
.
change
An event called whenever PermissionStatus.status
changes.
navigator.permissions .query({ name: "geolocation" }) .then((permissionStatus) => { console.log(`geolocation permission status is ${permissionStatus.state}`); permissionStatus.onchange = () => { console.log( `geolocation permission status has changed to ${permissionStatus.state}` ); }; });
Specification |
---|
Permissions # permissionstatus-interface |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
PermissionStatus |
43 | 79 | 46 | No | 30 | 16 | NoSee bug 490120. |
43 | 46 | 30 | 16 | 4.0 |
change_event |
43 | 79 | 46 | No | 30 | 16.4 | No | 43 | 46 | 30 | 16.4 | 4.0 |
name |
97 | 97 | 93 | No | 83 | 16 | No | 97 | 93 | 68 | 16 | 18.0 |
state |
4443–44 | 79 | 46 | No | 3130–31 | 16 | No | 4443–44 | 46 | 3230–32 | 16 | 4.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus