IdleDetector: userState property

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.

Thuộc tính chỉ đọc userState của giao diện IdleDetector trả về một chuỗi cho biết người dùng có tương tác với thiết bị kể từ lần gọi start() hay không.

Giá trị

Một trong hai giá trị "active" hoặc "idle" nếu IdleDetector.start() đã được gọi, hoặc null trong trường hợp ngược lại.

Ví dụ

Trong ví dụ dưới đây, callback change in trạng thái của userStatescreenState 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-userstate

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