Note that there are some explanatory texts on larger screens.

plurals
  1. POIndexedDB onversionchange event not fired in Chrome
    text
    copied!<p>I'm playing with the IndexedDB API from html5 spec in both Firefox and Chrome.</p> <p>There something that's not working as expected I and want to share it here because I don't know if it's my fault or a browser bug.</p> <p>According to the <a href="http://www.w3.org/TR/IndexedDB/#widl-IDBDatabase-onversionchange" rel="nofollow">API</a>, there's an event called <strong>onversionchange</strong> that's fired when you open a connection to a local database and the version number used is greater than the databases one. My problem is that this event is being fired in Firefox but not in Chrome.</p> <p>Some sample code trying several modes:</p> <pre><code>var db; var DB_VERSION = 5; var openRequest = iDb.open("test_db", DB_VERSION, function() { console.log("This is the place where I can change db structure"); }); openRequest.onSuccess = function(event) { db = openRequest.result; }; openRequest.onversionchange = function(event) { console.log("This is the place where I can change db structure"); }; openRequest.onupgradeneeded = function(event) { console.log("This is the place where I can change db structure"); }; </code></pre> <p>onversionchage event is not being fired even when I change the version number.</p> <p><strong>UPDATE</strong> As <em>ebidel</em> has answered, Chrome implementatio does not follow the currently specification so, in order to have a cross broswser client code, we need to handle two situations: <em>onversionchange</em> event and <em>database.version</em> manual comparision.</p> <p>Here are a couple on links with code example: <a href="http://groups.google.com/a/chromium.org/group/chromium-discuss/browse_thread/thread/5d96ca12c2d092b6?pli=1" rel="nofollow">Chromium google group</a> and <a href="http://www.html5rocks.com/en/tutorials/indexeddb/todo/" rel="nofollow">HTML5 Rocks!</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload