aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/indexeddb/index.html
blob: 81015fd45d1fb6531b44c7b8c7060c3ca158d724 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
title: WindowOrWorkerGlobalScope.indexedDB
slug: Web/API/indexedDB
tags:
  - API
  - Database
  - IndexedDB
  - Reference
  - Storage
  - WindowOrWorkerGlobalScope
  - 参考
  - 属性
translation_of: Web/API/WindowOrWorkerGlobalScope/indexedDB
original_slug: Web/API/WindowOrWorkerGlobalScope/indexedDB
---
<p>{{ APIRef() }}</p>

<p><strong><code>indexedDB</code></strong> 是 {{domxref("WindowOrWorkerGlobalScope")}}的一个只读属性,它集成了为应用程序提供异步访问索引数据库的功能的机制。.</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">var IDBFactory = self.indexedDB;</pre>

<div class="twocolumns">
<h2 id="值"></h2>
</div>

<p>一个 {{domxref("IDBFactory")}} 对象.</p>

<p id="示例">示例</p>

<pre class="brush: js;highlight:[3]">var db;
function openDB() {
 var DBOpenRequest = window.indexedDB.open('toDoList');
 DBOpenRequest.onsuccess = function(e) {
   db = DBOpenRequest.result;
 }
}</pre>

<h2 id="规范">规范</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 2', '#dom-windoworworkerglobalscope-indexeddb', 'indexedDB')}}</td>
   <td>{{Spec2('IndexedDB 2')}}</td>
   <td>Defined in a <code>WindowOrWorkerGlobalScope</code> partial in the newest spec.</td>
  </tr>
  <tr>
   <td>{{SpecName('IndexedDB', '#widl-IDBEnvironment-indexedDB', 'indexedDB')}}</td>
   <td>{{Spec2('IndexedDB')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>

{{Compat("api.indexedDB")}}

<h2 id="相关链接">相关链接</h2>

<ul>
 <li><a href="/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB">Using IndexedDB</a></li>
 <li>Starting transactions: {{domxref("IDBDatabase")}}</li>
 <li>Using transactions: {{domxref("IDBTransaction")}}</li>
 <li>Setting a range of keys: {{domxref("IDBKeyRange")}}</li>
 <li>Retrieving and making changes to your data: {{domxref("IDBObjectStore")}}</li>
 <li>Using cursors: {{domxref("IDBCursor")}}</li>
 <li>Reference example: <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a class="external" href="http://mdn.github.io/to-do-notifications/">view example live</a>.)</li>
</ul>