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
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
