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.

注意: 此特征可用于 Web 工作者 .

特性

DOMCursor.done

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

方法

DOMCursor.continue()

Moves the cursor to the next result.

范例

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();
  }
}
							

规范

Not currently part of any specification.

浏览器兼容性

Supported in Firefox 21.
Available in workers in Firefox 41.

Support removed in Firefox 61.

另请参阅

元数据

  • 最后修改: