Navigator.addIdleObserver()

Non-standard
This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

This API is available on Firefox OS for internal applications only.

Summary

This method is used to add an observer that will check if the user is idle and will act accordingly. Once an observer is added, it can be removed with Navigator.removeIdleObserver.

Syntax

navigator.addIdleObserver(IdleObserver);

Parameters

IdleObserver
An object with specific properties to handle if the user is idle or not; see IdleObserver below.

IdleObserver

The IdleObserver is any object with the three following properties:

time
The time (expressed in seconds) before the user is considered idle.
onidle
A function called when the user is considered idle.
onactive
A function called when the user becomes active again.

Example

var myObserver = {
  time: 10,
  onidle: function () {
    console.log("The user is idle for 10 seconds");
  },
  onactive: function () {
    console.log("The user is now active again");
  }
}
navigator.addIdleObserver(myObserver);

Specification

Not part of any specification yet; however, this API will be discussed at W3C as part of the System Applications Working Group.

See also

Document Tags and Contributors

 Contributors to this page: teoli, kscarfone, Sheppy, Jeremie, ztooner, sicking
 Last updated by: teoli,