MDN self-hosted library · e01.org

PermissionStatus: change event

Permissions API

Permissions API

The change event of the PermissionStatus interface fires whenever the PermissionStatus.state property changes.

Syntax

Use the event name in addEventListener():

addEventListener("change", (event) => { })

Alternatively, assign to the event handler property of the interface:

onchange = (event) => { }

Event type

A generic Event.

Example

navigator.permissions
  .query({ name: "geolocation" })
  .then((permissionStatus) => {
    console.log(`geolocation permission state is ${permissionStatus.state}`);
    permissionStatus.onchange = () => {
      console.log(
        `geolocation permission state has changed to ${permissionStatus.state}`,
      );
    };
  });

Specifications

Browser compatibility