User Preferences API
The preferences read-only property of the Navigator interface returns a PreferenceManager object for the current document. This is the entry point for the User Preferences API functionality.
Value
A PreferenceManager object.
Examples
Get color scheme preference
This example demonstrates how to query the user's preferred color scheme.
if (navigator.preferences.colorScheme.value === "dark") {
// The user prefers a dark color scheme.
} else {
// The user prefers a light color scheme.
}
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
