IDBFactory.open
with two parameters, name and version. See the compatibility table for more information on what browsers support what method.
The original, now obsolete open()
method of the IDBFactory
object requests opening a connection to a database. The method returns an IDBRequest
object immediately, and performs the open operation asynchronously. If the operation is successful, a success
event is fired on the request object returned from this method, with its result
attribute set to the new IDBDatabase
object for the connection.
If an error occurs while the database connection is being opened, then an error event is fired on the request object returned from this method.
var request = window.indexedDB.open("toDoList");
A IDBRequest
object on which subsequent events related to this request are fired.
var DBOpenRequest = window.indexedDB.open("toDoList"); DBOpenRequest.onerror = function(event) { console.log("Error loading database."); }; DBOpenRequest.onsuccess = function(event) { console.log("Database initialised"); // store the result of opening the database in the db variable. This is used a lot later on, for opening transactions and suchlike. db = request.result; };
This version of the open()
method is from an old version of the spec. The latest version is specified at the link below:
Specification | Status | Comment |
---|---|---|
Indexed Database API The definition of 'open()' in that specification. | Recommendation |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 23webkit 24 | 10 moz 16.0 (16.0) | 10, partial | 15 | 7.1 |
Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 4.4 | 22.0 (22.0) | 1.0.1 | 10 | 22 | No support |
IDBDatabase
IDBTransaction
IDBKeyRange
IDBObjectStore
IDBCursor
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/open-obsolete