IdleDetector: change event
Khả dụng hạn chế
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is available in Dedicated Web Workers.
Sự kiện change của giao diện IdleDetector được kích hoạt khi giá trị của userState hoặc screenState thay đổi.
Cú pháp
Sử dụng tên sự kiện trong các phương thức như addEventListener(), hoặc thiết lập thuộc tính trình xử lý sự kiện.
js
addEventListener("change", (event) => { })
onchange = (event) => { }
Loại sự kiện
Một Event thông thường.
Ví dụ
Trong ví dụ dưới đây, callback change in trạng thái của userState và screenState ra console.
js
idleDetector.addEventListener("change", () => {
const userState = idleDetector.userState;
const screenState = idleDetector.screenState;
console.log(`Idle change: ${userState}, ${screenState}.`);
});
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Idle Detection API> # api-idledetector-onchange> |