IDBEnvironment

您正在阅读此内容的英文版本,因为该语系尚未翻译。 帮助我们翻译此文章吧!

注意! : 对于 Firefox 52, the property defined in this mixin has been moved to the WindowOrWorkerGlobalScope mixin, and other browsers will follow suit. Look to that page for up-to-date details.  IndexedDB API

 IndexedDB API提供的帮助类IDBEnvironment包含了一个indexedDB 属性, 这个属性可以比较方便的操作IndexedDB. 它是由windowWorker 实现的最顶级 IndexedDB接口.

Note: 此特性在 Web Worker 中可用。

属性

IDBEnvironment.indexedDB 只读
该属性为应用程序提供了异步访问索引数据库(IndexedDB)的构件. 它包含一个 IDBFactory 对象

示例

下述代码演示了如何创建一个异步打开数据库的请求, 当该请求的onsuccess 回调被执行时, 该数据库被打开.

var db;
function openDB() {
 var DBOpenRequest = window.indexedDB.open("toDoList");
 DBOpenRequest.onsuccess = function(e) {
   db = DBOpenRequest.result;
 };
}

规范

规范 状态 说明
Indexed Database API 2.0
IDBEnvironment
Recommendation  

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
IDBEnvironmentChrome Full support 24
Full support 24
No support 23 — 57
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 16
Full support 16
No support 10 — 16
Prefixed
Prefixed Implemented with the vendor prefix: moz
IE Full support 10
Notes
Full support 10
Notes
Notes partial
Opera Full support 15Safari Full support 7WebView Android Full support YesChrome Android Full support 25Firefox Android Full support 22Opera Android Full support 14Safari iOS Full support 8Samsung Internet Android Full support Yes
Available in workersChrome Full support YesEdge Full support YesFirefox Full support 37IE ? Opera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 37Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

参考