Table of contents
The IDBEvironment interface of the IndexedDB API provides asynchronous access to a client-side database. It is implemented by window and worker objects.
About this document
This document was last updated on September 30, 2011 and follows the W3C Specifications (Editor's Draft) drafted on September 30, 2011. It was last verified on October 26, 2011.
Example
The following code opens a database asynchronously and make a request. In your code, you have to access the attribute with vendor prefixes, that is to say, you should use mozIndexedDB for Firefox and webkitIndexedDB for Chrome.
// Taking care of the browser-specific prefixes.
if ('webkitIndexedDB' in window) {
window.indexedDB = window.webkitIndexedDB;
window.IDBTransaction = window.webkitIDBTransaction;
} else if ('mozIndexedDB' in window) {
window.indexedDB = window.mozIndexedDB;
}
...
var db;
function openDB() {
var request = indexedDB.open("creatures");
request.onsuccess = function(e) {
db = request.result;
}
}
Attributes
| Attribute | Type | Description |
|---|---|---|
indexedDB | readonly IDBFactory | Provides a mechanism for applications to asynchronously access capabilities of indexed databases. Note: Until the Indexed DB API specification is finalized, access this attribute with mozIndexedDB for Firefox and webkitIndexedDB for Chrome.
|


Mozilla Developer Network