{{APIRef("IndexedDB")}}
The IDBEnvironment
interface of the IndexedDB API contains the indexedDB
property, which provides access to IndexedDB functionality. It is the top level IndexedDB interface implemented by the {{domxref("window")}} and {{domxref("Worker")}} objects.
{{AvailableInWorkers}}
Properties
- {{domxref("IDBEnvironment.indexedDB")}} {{readonlyInline}}
- Provides a mechanism for applications to asynchronously access capabilities of indexed databases; contains an {{domxref("IDBFactory")}} object.
Example
The following code creates a request for a database to be opened asychronously, after which the database is opened when the request's onsuccess
handler is fired:
var db; function openDB() { var DBOpenRequest = window.indexedDB.open("toDoList"); DBOpenRequest.onsuccess = function(e) { db = DBOpenRequest.result; }; }
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('IndexedDB', '#idl-def-IDBEnvironment', 'IDBEnvironment')}} | {{Spec2('IndexedDB')}} |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 23{{property_prefix("webkit")}} 24 |
10 {{property_prefix("moz")}} {{CompatGeckoDesktop("16.0")}} |
10, partial | 15 | 7.1 |
Available in workers | {{CompatVersionUnknown}} | {{CompatGeckoMobile("37.0")}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 4.4 | {{CompatGeckoMobile("22.0")}} | 1.0.1 | 10 | 22 | 8 |
Available in workers | {{CompatVersionUnknown}} | {{CompatGeckoMobile("37.0")}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} |
Be careful in Chrome as it still implements the old specification along with the new one. Similarly it still has the prefixed webkitIndexedDB
property even if the unprefixed indexedDB
is present.
See also
- Using IndexedDB
- Starting transactions: {{domxref("IDBDatabase")}}
- Using transactions: {{domxref("IDBTransaction")}}
- Setting a range of keys: {{domxref("IDBKeyRange")}}
- Retrieving and making changes to your data: {{domxref("IDBObjectStore")}}
- Using cursors: {{domxref("IDBCursor")}}
- Reference example: To-do Notifications (view example live.)