mozilla

Revision 63465 of IDBOpenDBRequest

  • Revision slug: IndexedDB/IDBOpenDBRequest
  • Revision title: IDBOpenDBRequest
  • Revision id: 63465
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment page created, 169 words added

Revision Content

The IDBOpenDBRequest interface of the IndexedDB API provides access to results of requests to open databases using specific event handler attributes. It is an IDBRequest with a few more attributes.

Inherits from: IDBRequest

Example

In the following code snippet, we open a database asynchronously and make a request. Event handlers are registered for responding to various situations.

var request = window.indexedDB.open('Database Name');
request.onsuccess = function(event) {
        var db = this.result;
        var transaction = db.transaction([], IDBTransaction.READ_ONLY);
        var curRequest = transaction.objectStore('ObjectStore Name').openCursor();
        curRequest.onsuccess = ...;
    };
request.onerror = function(event) {
         ...;
    };

Attributes

Attribute Type Description
onblocked Function The event handler for the blocked event.
onupgradeneeded Function The event handler for the upgrade needed event.

Event handlers

Event handler Event handler type
onblocked error
onupgradeneeded success

Derived interface

No derived interface

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{ CompatNo() }} {{ CompatGeckoDesktop("10.0") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} {{ CompatGeckoMobile("6.0") }} {{ CompatUnknown() }} {{ CompatNo() }} {{ CompatNo() }}

Revision Source

<p>The <code>IDBOpenDBRequest</code> interface of the IndexedDB API provides access to results of requests to open databases using specific event handler attributes. It is an <code>IDBRequest</code> with a few more attributes.</p>
<p>Inherits from: <a href="/en/IndexedDB/IDBRequest" title="IDBRequest"><code>IDBRequest</code></a></p>
<h3>Example</h3>
<p>In the following code snippet, we open a database asynchronously and make a request. Event handlers are registered for responding to various situations.</p>
<pre class="eval deki-transform">var request = window.<strong>indexedDB</strong>.<strong>open</strong>('Database Name');
request.onsuccess = function(event) {
        <strong>var db = this.result</strong>;
        var transaction = db.<strong>transaction</strong>([], <strong>IDBTransaction.READ_ONLY</strong>);
        var curRequest = transaction.<strong>objectStore</strong>('ObjectStore Name').<strong>openCursor</strong>();
        curRequest.<strong>onsuccess</strong> = ...;
    };
request.onerror = function(event) {
         ...;
    };
</pre>
<h2>Attributes</h2>
<table class="standard-table"> <thead> <tr> <th scope="col" width="145">Attribute</th> <th scope="col" width="209">Type</th> <th scope="col" width="842">Description</th> </tr> <tr> <td><code>onblocked</code></td> <td><code>Function </code></td> <td>The event handler for the blocked event.</td> </tr> <tr> <td><code>onupgradeneeded</code></td> <td><code>Function </code></td> <td>The event handler for the upgrade needed event.</td> </tr> </thead> <tbody> </tbody>
</table>
<h2>Event handlers</h2>
<table border="1" cellpadding="1" cellspacing="1" class="standard-table"> <thead> <tr> <th scope="col" width="133">Event handler</th> <th scope="col" width="129">Event handler type</th> </tr> </thead> <tbody> <tr> <td><code>onblocked </code></td> <td><code>error </code></td> </tr> <tr> <td><code>onupgradeneeded</code></td> <td><code>success </code></td> </tr> </tbody>
</table>
<h2>Derived interface</h2>
<p><em>No derived interface</em></p>
<h2 name="Browser_Compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<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>{{ CompatNo() }}</td> <td>{{ CompatGeckoDesktop("10.0") }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</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>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatNo() }}</td> <td>{{ CompatGeckoMobile("6.0") }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> </tr> </tbody> </table>
</div>
Revert to this revision