PermissionStatus: name property
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2022.
Note: This feature is available in Web Workers.
The name read-only property of the PermissionStatus interface returns the name of a requested permission.
Value
A read-only value that is identical to the name argument passed to navigator.permissions.query().
Examples
js
function stateChangeListener() {
console.log(`${this.name} permission status changed to ${this.state}`);
}
function queryAndTrackPermission(permissionName) {
navigator.permissions
.query({ name: permissionName })
.then((permissionStatus) => {
console.log(
`${permissionName} permission state is ${permissionStatus.state}`,
);
permissionStatus.onchange = stateChangeListener;
});
}
queryAndTrackPermission("geolocation");
queryAndTrackPermission("midi");
Specifications
| Specification |
|---|
| Permissions # dom-permissionstatus-name |
Browser compatibility
| desktop | mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
name
|
|
|
|
|
|
|
|
|
|
|
|
|
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support