Why does window.indexedDB evaluate to undefined? (How to use IndexedDB?)

I am messing around with HTML5's IndexedDB.

Below is a simple code from http://html5-demos.appspot.com/static/html5storage/index.html#slide31 that is not working for me in Chrome or Firefox, it is giving me this message in Firebug:

Uncaught TypeError: Cannot call method 'open' of undefined`

for the 1st line of the code, which is:

var db = window.indexedDB.open('FriendDB', 'My Friends!');  // exception here

Can someone help me to get this working please?

There is a JSFiddle running the code

I know this works on the browser because this interactive slide works: http://html5-demos.appspot.com/static/html5storage/index.html#slide34


You have to use the prefixed version for each browser (window.webkitIndexedDB or window.mozIndexedDB). Then you can do something like:

window.indexedDB = window.indexedDB
                     || window.webkitIndexedDB
                     || window.mozIndexedDB;

and then use window.indexedDB everywhere in your code.

Need Your Help

TextField formatting (padding) issue in Titanium Android

android formatting textfield titanium-mobile titanium-android

I am facing the issue of formatting a simple textfield in Titanium Android.

Linux magic quotes still on even though disabled in php5 fpm .ini file

php linux nginx php-fpm magic-quotes-gpc

So I installed nginx not too long ago, and I can't figure out how to turn off magic_quotes_gpc. In the php5-fpm php.ini it has the following lines: