PermissionStatus: state property
The state
read-only property of the
PermissionStatus
interface returns the state of a requested permission.
This property returns one of 'granted'
, 'denied'
, or
'prompt'
.
Value
One of the following:
'granted'
'denied'
'prompt'
Examples
js
navigator.permissions
.query({ name: "geolocation" })
.then((permissionStatus) => {
console.log(`geolocation permission state is ${permissionStatus.state}`);
permissionStatus.onchange = () => {
console.log(
`geolocation permission status has changed to ${permissionStatus.state}`
);
};
});
Specifications
Specification |
---|
Permissions # dom-permissionstatus-state |
Browser compatibility
BCD tables only load in the browser