The PermissionStatus interface of the Permissions API provides the state of an object and an event handler for monitoring changes to said state.
On this page
PermissionStatus
Instance properties
PermissionStatus.nameRead only-
Returns the name of a requested permission, identical to the
namepassed toPermissions.query. PermissionStatus.stateRead only-
Returns the state of a requested permission; one of
'granted','denied', or'prompt'. PermissionStatus.statusRead only Deprecated-
Returns the state of a requested permission; one of
'granted','denied', or'prompt'. Later versions of the specification replace this withPermissionStatus.state.
Events
-
change -
Invoked upon changes to
PermissionStatus.state, or the deprecatedPermissionStatus.statusin the case of older browsers.
Example
js
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}`,
);
};
});
Specifications
| Specification |
|---|
| Permissions # permissionstatus-interface |
Browser compatibility
| 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 | No | 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