Your Search Results

    IDBDatabase.onerror

    This article is in need of a technical review.

    « IDBDatabase

    The IDBDatabase.onerror event handler returns when when access to the database fails.

    Syntax

    attribute  EventHandler  onerror;

    Example

    eventrequest.onupgradeneeded = function(event) {
      var db = event.target.result;
        
      db.onerror = function(event) {
        note.innerHTML += '<li>Error opening database.</li>';
      };
    
      db.onabort = function(event) {
        note.innerHTML += '<li>Database opening aborted!</li>';
      };
    
      // Create an objectStore for this database
        
      var objectStore = db.createObjectStore("toDoList", { keyPath: "taskTitle" });
        
      // define what data items the objectStore will contain
        
      objectStore.createIndex("hours", "hours", { unique: false });
      objectStore.createIndex("minutes", "minutes", { unique: false });
      objectStore.createIndex("day", "day", { unique: false });
      objectStore.createIndex("month", "month", { unique: false });
      objectStore.createIndex("year", "year", { unique: false });
    
      objectStore.createIndex("notified", "notified", { unique: false });
        
      note.innerHTML += '<li>Object store created.</li>';
    };

    Specifications

    Specification Status Comment
    Indexed Database API Candidate Recommendation  

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
    Basic support

    12webkit
    23 without prefix

    4.0 (2.0) 10 17 Not supported
    Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
    Basic support 4.4 6.0 (6.0) 1.0.1 10 17 Not supported

    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 will make sense in the context of this application.

    Document Tags and Contributors

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