PreferenceObject: change event

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

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The change event of the PreferenceObject interface is fired on a specific PreferenceObject its override value 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.

Examples

js
navigator.preferences.colorScheme.addEventListener("change", (event) => {
  console.log(navigator.preferences.colorScheme.value);
});

Specifications

Specification
Media Queries Level 5
# onchange-attribute

Browser compatibility

See also