Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Navigator.addIdleObserver()

Nasi wolontariusze nie przetłumaczyli jeszcze tego artykułu na język Polski. Dołącz do nas i pomóż go przetłumaczyć!

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

Autorzy i etykiety dokumentu

 Autorzy tej strony: teoli, kscarfone, Sheppy, Jeremie, ztooner, Sicking
 Ostatnia aktualizacja: teoli,