Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 668851 of IDBEnvironment

  • Revision slug: Web/API/IDBEnvironment
  • Revision title: IDBEnvironment
  • Revision id: 668851
  • Created:
  • Creator: chrisdavidmills
  • Is current revision? No
  • Comment

Revision Content

{{APIRef()}}

The IDBEnvironment interface of the IndexedDB API provides asynchronous access to a client-side database. It is implemented by {{domxref("window")}} and {{domxref("Worker")}} objects.

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 opens a database asynchronously and makes a request.

var db;
function openDB() {
 var DBOpenRequest = window.indexedDB.open("toDoList");
 DBOpenRequest.onsuccess = function(e) {
   db = request.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 12{{property_prefix("webkit")}}
23
{{CompatGeckoDesktop("2.0")}} 10 17 {{CompatNo}}
Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support 4.4 {{CompatGeckoMobile("6.0")}} 1.0.1 10 17 {{CompatNo}}

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

To learn more about various topics, see the following

  • Starting transactions: {{domxref("IDBDatabase")}}
  • Setting transaction modes: {{domxref("IDBTransaction")}}
  • Setting a range of keys: {{domxref("IDBKeyRange")}}
  • Creating cursors: {{domxref("IDBIndex")}}
  • The reference application for the examples in this reference: To-do Notifications (view example live.)

Revision Source

<p>{{APIRef()}}</p>
<div class="summary">
 <p>The <strong><code>IDBEnvironment</code></strong> interface of the <a href="/en-US/docs/IndexedDB">IndexedDB API</a> provides asynchronous access to a client-side database. It is implemented by {{domxref("window")}} and {{domxref("Worker")}} objects.</p>
</div>
<h2 id="Properties">Properties</h2>
<dl>
 <dt>
  {{domxref("IDBEnvironment.indexedDB")}} {{readonlyInline}}</dt>
 <dd>
  Provides a mechanism for applications to asynchronously access capabilities of indexed databases; contains an {{domxref("IDBFactory")}} object.</dd>
</dl>
<h2 id="Example">Example</h2>
<p>The following code opens a database asynchronously and makes a request.</p>
<pre class="brush: js;highlight:[3]">
var db;
function openDB() {
 var DBOpenRequest = window.indexedDB.open("toDoList");
 DBOpenRequest.onsuccess = function(e) {
   db = request.result;
 }
}
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('IndexedDB', '#idl-def-IDBEnvironment', 'IDBEnvironment')}}</td>
   <td>{{Spec2('IndexedDB')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<div>
 {{CompatibilityTable}}</div>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari (WebKit)</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>12{{property_prefix("webkit")}}<br />
     23</td>
    <td>{{CompatGeckoDesktop("2.0")}}</td>
    <td>10</td>
    <td>17</td>
    <td>{{CompatNo}}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>Firefox OS</th>
    <th>IE Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>4.4</td>
    <td>{{CompatGeckoMobile("6.0")}}</td>
    <td>1.0.1</td>
    <td>10</td>
    <td>17</td>
    <td>{{CompatNo}}</td>
   </tr>
  </tbody>
 </table>
</div>
<div class="warning">
 <p>Be careful in Chrome as it still implements the old specification along with the new one. Similarly it still has the prefixed <code>webkitIndexedDB</code> property even if the unprefixed <code>indexedDB</code> is present.</p>
</div>
<h2 id="See_also">See also</h2>
<p>To learn more about various topics, see the following</p>
<ul>
 <li>Starting transactions: {{domxref("IDBDatabase")}}</li>
 <li>Setting transaction modes: {{domxref("IDBTransaction")}}</li>
 <li>Setting a range of keys: {{domxref("IDBKeyRange")}}</li>
 <li>Creating cursors: {{domxref("IDBIndex")}}</li>
 <li>The reference application for the examples in this reference: <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a class="external" href="https://mdn.github.io/to-do-notifications/">view example live</a>.)</li>
</ul>
Revert to this revision