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

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

Value

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

Example

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

Specifications

Specification Status Comment
Indexed Database API 2.0
The definition of 'onclose' in that specification.
Recommendation  

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 31
Notes
Full support 31
Notes
Notes approx
Edge Full support YesFirefox Full support 50IE ? Opera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 50Opera Android Full support YesSafari iOS Full support 10.1Samsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

Document Tags and Contributors

Contributors to this page: fscholz, jpmedley, teoli, Sheppy
Last updated by: fscholz,