This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
The PermissionStatus
interface of the Permissions API provides the state of an object and an event handler for monitoring changes to said state.
Properties
PermissionStatus.state
Read only- Returns the state of a requested permission; one of
'granted'
,'denied'
, or'prompt'
. PermissionStatus.status
Read only- Returns the state of a requested permission; one of
'granted'
,'denied'
, or'prompt'
. Later versions of the specification replace this withPermissionStatus.state
.
Event Handler
PermissionStatus.onchange
- An event called whenever
PermissionStatus.status
changes.
Example
navigator.permissions.query({name:'geolocation'}).then(function(permissionStatus) { console.log('geolocation permission status is ', permissionStatus.state); permissionStatus.onchange = function() { console.log('geolocation permission status has changed to ', this.state); }; });
Specification
Specification | Status | Comment |
---|---|---|
Permissions API The definition of 'PermissionStatus' in that specification. |
Editor's Draft | Initial definition. |