onabort
event handler of the
IDBDatabase
interface handles the abort event, fired when a transaction is aborted and bubbles up to the connection object.
IDBDatabase.onabort = function(event) { ... };
This example shows an
IDBOpenDBRequest.onupgradeneeded
block that creates a new object store; it also includes
onerror
and
onabort
functions to handle non-success cases.
DBOpenRequest.onupgradeneeded = function(event) {
var db = event.target.result;
db.onerror = function() {
note.innerHTML += '<li>Error opening database.</li>';
};
db.onabort = function() {
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>';
};
| 规范 | 状态 | 注释 |
|---|---|---|
|
索引数据库 API 2.0
在该规范中的 onabort 定义。 |
推荐 | |
|
索引数据库 API 草案
在该规范中的 onabort 定义。 |
推荐 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onabort
|
Chrome
24
|
Edge 12 |
Firefox
16
|
IE 部分支持 10 | Opera 15 | Safari 7 | WebView Android Yes | Chrome Android 25 | Firefox Android 22 | Opera Android 14 | Safari iOS 8 | Samsung Internet Android 1.5 |
完整支持
部分支持
要求使用供应商前缀或不同名称。
IDBDatabase
IDBTransaction
IDBKeyRange
IDBObjectStore
IDBCursor
abort
event
IDBDatabase
IDBCursor
IDBCursorSync
IDBCursorWithValue
IDBDatabaseException
IDBDatabaseSync
IDBEnvironment
IDBEnvironmentSync
IDBFactory
IDBFactorySync
IDBIndex
IDBIndexSync
IDBKeyRange
IDBObjectStore
IDBObjectStoreSync
IDBOpenDBRequest
IDBRequest
IDBTransaction
IDBTransactionSync
IDBVersionChangeEvent
IDBVersionChangeRequest