MDN self-hosted library · e01.org

PreferenceObject: override property

User Preferences API

Open notebook · 1 cells web-api-instance-property upstream source

User Preferences API

The override read-only property of the PreferenceObject interface returns the override of a preference if one is set, null otherwise.

Value

The override of the PreferenceObject interface, if set, or null if an override is not set.

Examples

Basic usage

This example demonstrates how to disambiguate between the color scheme preference set by the user agent vs a programmatic override.

if (navigator.preferences.colorScheme.override === null) {
  console.log(
    "The user agent set the following color scheme:",
    navigator.preferences.colorScheme.value,
  );
} else {
  console.log(
    "The following color scheme was set programmatically:",
    navigator.preferences.colorScheme.override,
  );
}

Specifications

Browser compatibility