Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. IdleDetector
  4. userState

IdleDetector: userState property

Limited availability

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 insecure contexts (HTTPS), in some or allsupporting browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Note: This feature is available inDedicated Web Workers.

TheuserState read-only property of theIdleDetector interface returns a string indicating whether the user has interacted with the device since the call tostart().

Value

Either"active" or"idle" ifIdleDetector.start() has been called, ornull otherwise.

Examples

In the following example, thechange callback prints the status ofuserState andscreenState to the console.

js
idleDetector.addEventListener("change", () => {  const userState = idleDetector.userState;  const screenState = idleDetector.screenState;  console.log(`Idle change: ${userState}, ${screenState}.`);});

Specifications

Specification
Idle Detection API
# api-idledetector-userstate

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp