PreferenceObject: phương thức requestOverride()
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.
Phương thức requestOverride của giao diện PreferenceObject đặt giá trị must be provided cho một tùy chọn cụ thể.
Cú pháp
js
requestOverrides(value)
Tham số
value-
Giá trị cần yêu cầu ghi đè.
Giá trị trả về
Một Promise giải quyết thành undefined khi thành công, hoặc bị từ chối khi thất bại.
Ngoại lệ
NotAllowedErrorDOMException-
Được ném ra nếu giá trị đã cho không được phép.
Ví dụ
>Sử dụng cơ bản
Ví dụ sau yêu cầu ghi đè must be provided.
js
await navigator.preferences.colorScheme.requestOverride("dark");
console.log(navigator.preferences.colorScheme.override);
Thông số kỹ thuật
| Specification |
|---|
| Media Queries Level 5> # request-override-method> |