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.
IDBDatabase.onclose = function(error) { ... };
A function which is called when the close
event is fired.
db.onclose = function(event) { myAppShowAlert('The database "' + db.name + '" has unexpectedly closed.'); };
Specification | Status | Comment |
---|---|---|
Indexed Database API 2.0 The definition of 'onclose' in that specification. | Recommendation |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 31
|
Yes | 50 | ? | Yes | 10.1 |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | 50 | Yes | 10.1 | Yes |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase/onclose