PreferenceObject: thuộc tính value

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 value của giao diện PreferenceManager trả về giá trị ghi đè của một tùy chọn nếu đã được đặt, hoặc giá trị do UA xác định nếu không có giá trị ghi đè.

Giá trị

Giá trị ghi đè của giao diện PreferenceObject nếu đã được đặt, hoặc giá trị do UA xác định nếu không.

Ví dụ

Sử dụng cơ bản

Ví dụ này minh họa cách truy vấn tùy chọn reduced motion của người dùng.

js
if (navigator.preferences.reducedMotion.value === "reduce") {
  // The user prefers reduced motion.
} else {
  // The user has stated no preference regarding motion.
}

Thông số kỹ thuật

Specification
Media Queries Level 5
# preference-value-attribute

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