onclose event handler of the IDBDatabase interface handles the close event, which is fired when the database is unexpectedly closed. This can happen, for example, when the application is shut down or access to the disk the database is stored on is lost while the database is open.

close event is fired after all transactions have been aborted and the connection has been closed.

注意: 此特征可用于 Web 工作者 .

句法

IDBDatabase.onclose = function(event) { ... };
					

A function which is called when the close event is fired.

范例

db.onclose = function(event) {
  myAppShowAlert('The database "' + db.name + '" has unexpectedly closed.');
};
					

规范

规范 状态 注释
索引数据库 API 草案
The definition of 'onclose' in that specification.
推荐

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
onclose Chrome 31 注意事项
31 注意事项
approx
Edge ≤18 Firefox 50 IE ? Opera Yes Safari 10.1 WebView Android Yes Chrome Android 31 Firefox Android 50 Opera Android Yes Safari iOS 10.3 Samsung Internet Android 2.0

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

见实现注意事项。

另请参阅

元数据

  • 最后修改: