IDBDatabase.onclose

The 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.

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

Note: This feature is available in Web Workers.

Syntax

JavaScript
IDBDatabase.onclose = function;

Value

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

Example

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

Specifications

Specification Status Comment
Indexed Database API (Second Edition)
The definition of 'onclose' in that specification.
Recommendation  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 31 (approx.) 50 (50) ? ? ?
Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support ? 50.0 (50) ? ? ? ?

See also

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/idbdatabase/onclose

API Event Handler IDBDatabase IndexedDB onclose Property Reference