DOMCursor

This article is in need of a technical review.

« DOM Reference

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

Summary

A DOMCursor object represents an ongoing operation over a list of results. It is an enhanced DOMRequest that allows to iterate through a list of results asynchronously. Each time its continue() method is called, the DOMCursor tries to reach the next result in the list and calls its result's success or error accordingly.

Properties

DOMCursor.done
A boolean indicating if the cursor has reached the last result.

Inherited from DOMRequest:

DOMRequest.onsuccess
A callback handler called when the operation represented by the DOMRequest is completed.
DOMRequest.onerror
A callback handler that gets called when an error occurs while processing the operation.
DOMRequest.readyState
A string indicating whether or not the operation is finished running. Its value is either "done" or "pending".
DOMRequest.result
The operation's result.
DOMRequest.error
Error information, if any.

Methods

DOMCursor.continue()
Moves the cursor to the next result.

Example

var sdcard = navigator.getDeviceStorage('sdcard');
var cursor = sdcard.enumerate();

cursor.onsuccess = function () {
  console.log("File found: " + this.result.name);

  // Once we found a file we check if there is other results
  if (!this.done) {
    // Then we move to the next result, which call the
    // cursor success with the next file as result.
    this.continue();
  }
}

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? 21.0 (21.0) ? ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? 21.0 (21.0) ? ? ?

Specification

Not currently part of any specification.

See also

Document Tags and Contributors

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