PermissionStatus: name property
Baseline 2022Newly available
Since September 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
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
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.