Your Search Results


    This article is in need of a technical review.

    « IDBIndex

    The IDBIndex.openKeyCursor method returns an IDBRequest object, and, in a separate thread, creates a cursor over the specified key range, as arranged by this index.

    The method sets the position of the cursor to the appropriate key, based on the specified direction.

    • If the key range is not specified or is null, then the range includes all the keys.
    • If at least one key matches the key range, then a success event is fired on the result object, with its result set to the new IDBCursor object; the value of the cursor object is set to the value of the found record.
    • If no keys ranges match the key range specified, then then an error event is fired on the request object.


    IDBRequest openKeyCursor (optional any range, optional IDBCursorDirection direction = "next");


    Opening a transaction and using openKeyCursor to step through the entire data set:

    // Open our object store and then get a cursor list of all the different data items in the IDB to iterate through
        var objectStore = db.transaction('toDoList').objectStore('toDoList');
        objectStore.openKeyCursor().onsuccess = function(event) {
          var cursor =;
            // if there is still another cursor to go, keep runing this code
            if(cursor) {
              console.log("Task for item" + cursor.key + " is " + cursor.value.taskTitle);
              // continue on to the next item in the cursor
            // if there are no more cursor items to iterate through, say so, and exit the function
            } else {
              note.innerHTML += '<li>Entries all displayed.</li>';


    Optional. The key range to use as the cursor's range.
    Optional. The cursor's required direction. See IDBCursor Constants for possible values.


    A request object on which subsequent events related to this operation are fired.


    This method may raise a DOMException with a DOMError of the following types:

    Exception Description
    TransactionInactiveError This IDBIndex's transaction is inactive.
    TypeError The value for the direction parameter is invalid.

    The key or key range provided contains an invalid key.

    InvalidStateError The IDBIndex has been deleted or removed.


    Specification Status Comment
    Indexed Database API Candidate Recommendation  

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
    Basic support 12-webkit
    4.0 (2.0) 10 17 Not supported
    count() 23 10.0 (10.0) 10 17 Not supported
    getAll() and getAllKeys() Not supported 24.0 (24.0)
    behind dom.indexedDB.experimental  pref
    Not supported Not supported Not supported
    Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
    Basic support 4.4 4.0 (2.0) 1.0.1 10 17 Not supported
    count() 4.4 10.0 (10.0) 1.0.1 10 17 Not supported
    getAll() and getAllKeys() Not supported 24.0 (24.0)
    behind dom.indexedDB.experimental  pref
    1.1 behind
    dom.indexedDB.experimental  pref
    Not supported Not supported Not supported

    Be careful in Chrome as it still implements the old specification along the new one. Similarly it still has the prefixed webkitIndexedDB property even if the unprefixed indexedDB is present.

    See also

    • Using IndexedDB
    • The reference application for the examples in this reference: To-do Notifications (view example live.) Not every snippet appears in this example, but every example uses the same data structure and syntax, and they will make sense in the context of this example.



    Document Tags and Contributors

    Contributors to this page: chrisdavidmills
    Last updated by: chrisdavidmills,