IndexedDB only works from HTTP/HTTPS site

Just spent a couple of days googling for an answer to why the window.indexedDB returned null in IE 10 and Firefox 16 when testing my HTML. Chrome and old Firefox versions return values (window.webkitIndexedDB and window.mozIndexedDB).

Turns out that access to IndexedDB is not allowed via the file:// protocol for local access. The answer lay in StackOverflow: http://stackoverflow.com/questions/13120236/window-mozindexdb-is-null-in-firefox-14-to-16-version, referring to http://msdn.microsoft.com/en-us/library/ie/hh779017%28v=vs.85%29.aspx and the following note:

“For security reasons, Indexed Database API only works through the http, https, ms-wwa, or ms-wwa-web protocols in Windows Internet Explorer. That is, Internet Explorer doesn’t allow a local HTML page ( file://) to fully execute the Indexed Database API. Instead, the page must be behind a supported protocol such as http:// or https://.”

So, put your test-html on a webserver.

I assume that this will also be the case in Chrome (and Safari) once they finish their implementation of this new HTML5 standard – please, Apple in particular, haul ass!

So for now on to getting a small sample to work in Safari as well with the IndexedDB polyfill.

I also need to do work on synchronization with a backend – we live in interesting times! PouchDB seems one way, this StackOverflow answer seems another path to take, but (simple) samples and libraries seem hard to find.

Advertisements
Posted in Web

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s