GO-V.ORG
As seen in

PermissionStatus: state property

Permissions API

Permissions API

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'`
- : The user, or the user agent on the user's behalf, has given express permission to use a [powerful feature](https://w3c.github.io/permissions/#dfn-powerful-feature). The caller can use the feature possibly without having the user agent ask the user's permission.
- `'denied'`
- : The user, or the user agent on the user's behalf, has denied access to this [powerful feature](https://w3c.github.io/permissions/#dfn-powerful-feature). The caller can't use the feature.
- `'prompt'`
- : The user has not given express permission to use the feature (_i.e., it's the same as denied_). It also means that if a caller attempts to use the feature, the user agent will either be prompting the user for permission or access to the feature will be denied.

## 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

## Browser compatibility

source: MDN Web Docs mirror · page

Cite this

"PermissionStatus: state property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus/state

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·