PermissionStatus.name

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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(function(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