IndexedDB API の IDBOpenDBRequest インターフェイスは、特定のイベントハンドラー属性を使用して、データベースを開くまたは削除する要求の結果へのアクセスを提供します(IDBFactory.open および IDBFactory.deleteDatabase を使用して実行されます)。
注:この機能は Web Workers で使用できます。
また、親 IDBRequest および EventTarget からメソッドを継承します。
メソッドなし、ただし、親 IDBRequest および EventTarget からメソッドを継承します。
親インターフェースで定義されたイベント、IDBRequest および EventTarget、IDBOpenDBRequest オブジェクトにディスパッチすることもできます。
addEventListener() を使用するか、このインターフェイスの oneventname プロパティにイベントリスナーを割り当てることにより、これらの一般的で特定のイベントをリッスンします。
このインターフェイスに固有のイベントは次のとおりです:
var db;
// Let us open our database
var DBOpenRequest = window.indexedDB.open("toDoList", 4);
// these event handlers act on the database being opened.
DBOpenRequest.onerror = function(event) {
  note.innerHTML += '<li>Error loading database.</li>';
};
DBOpenRequest.onsuccess = function(event) {
  note.innerHTML += '<li>Database initialized.</li>';
  // store the result of opening the database in the db
  // variable. This is used a lot below
  db = DBOpenRequest.result;
  // Run the displayData() function to populate the task
  // list with all the to-do list data already in the IDB
  displayData();
};
// This event handles the event whereby a new version of
// the database needs to be created Either one has not
// been created before, or a new version number has been
// submitted via the window.indexedDB.open line above
// it is only implemented in recent browsers
DBOpenRequest.onupgradeneeded = function(event) {
  var db = this.result;
  db.onerror = function(event) {
    note.innerHTML += '<li>Error loading database.</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 });
};
| 表示内容: | 
| 表示内容: |