IDBVersionChangeEvent: IDBVersionChangeEvent() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The IDBVersionChangeEvent() constructor creates a new IDBVersionChangeEvent object, which is used to represent when a version of the database has changed, as a result of the onupgradeneeded event handler.

Syntax

js
new IDBVersionChangeEvent(type)
new IDBVersionChangeEvent(type, options)

Parameters

type

A string with the name of the event. It is case-sensitive and browsers set it to versionchange, success, or blocked.

options Optional

An object that, in addition of the properties defined in Event(), can have the following properties:

oldVersion Optional

A number representing the previous version of the database. It defaults to 0.

newVersion Optional

An unsigned long representing the new version of the database, or null if the database is being deleted. It defaults is null.

Return value

A new IDBVersionChangeEvent object.

Examples

For a full working example, see our To-do Notifications app (view example live).

Specifications

Specification
Indexed Database API 3.0
# dom-idbversionchangeevent-idbversionchangeevent

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
IDBVersionChangeEvent() constructor
Chrome – Full support
Chrome 41 (Release date: 2015-03-03)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 25 (Release date: 2013-10-29)
footnote Full support
Opera – Full support
Opera 28 (Release date: 2015-03-10)
footnote Full support
Safari – Full support
Safari 10 (Release date: 2016-09-20)
footnote Full support
Chrome Android – Full support
Chrome Android 41 (Release date: 2015-03-11)
footnote Full support
Firefox for Android – Full support
Firefox for Android 25 (Release date: 2013-10-29)
footnote Full support
Opera Android – Full support
Opera Android 28 (Release date: 2015-03-10)
footnote Full support
Safari on iOS – Full support
Safari on iOS 10 (Release date: 2016-09-13)
footnote Full support
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote Full support
WebView Android – Full support
WebView Android 41 (Release date: 2015-03-11)
footnote Full support
WebView on iOS – Full support
WebView on iOS 10 (Release date: 2016-09-13)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support