PermissionStatus.name

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

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

BCD tables only load in the browser