PreferenceObject: thuộc tính override

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.

Thuộc tính chỉ đọc override của giao diện PreferenceObject trả về giá trị ghi đè của một tùy chọn nếu đã được đặt, hoặc null nếu không.

Giá trị

Giá trị ghi đè của giao diện PreferenceObject, nếu được đặt, hoặc null nếu không có giá trị ghi đè nào được đặt.

Ví dụ

Sử dụng cơ bản

Ví dụ này minh họa cách phân biệt giữa giao diện màu được đặt bởi user agent và giá trị ghi đè theo chương trình.

js
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,
  );
}

Thông số kỹ thuật

Thông số kỹ thuật
Media Queries Level 5
# override-attribute

Tương thích trình duyệt