PermissionStatus: change event

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Note: This feature is available in Web Workers.

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

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

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

onchange = (event) => { }

Event type

A generic Event.

Example

js
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

Specification
Permissions
# dom-permissionstatus-onchange

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
change event
Chrome – Full support
Chrome 43 (Release date: 2015-05-19)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 46 (Release date: 2016-04-26)
footnote Full support
Opera – Full support
Opera 30 (Release date: 2015-06-09)
footnote Full support
Safari – Partial support
Safari 16.4 (Release date: 2023-03-27)
footnote Partial support
footnote The onchange event handler is supported, but the event never fires. See bug 259432.
Chrome Android – Full support
Chrome Android 43 (Release date: 2015-05-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 46 (Release date: 2016-04-26)
footnote Full support
Opera Android – Full support
Opera Android 30 (Release date: 2015-06-10)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Partial support
footnote The onchange event handler is supported, but the event never fires. See bug 259432.
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote Full support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Partial support
WebView on iOS 16.4 (Release date: 2023-03-27)
footnote Partial support
footnote The onchange event handler is supported, but the event never fires. See bug 259432.

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support