Movatterモバイル変換


[0]ホーム

URL:


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

IdleDetector: change event

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.

Thechange event of theIdleDetector interface fires when the value ofuserState orscreenState has changed.

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("change", (event) => { })onchange = (event) => { }

Event type

A genericEvent.

Example

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-onchange

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp