Window.mozIndexedDB is null in Firefox 15

I am trying to run the "Using IndexedDB" sample code at https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB

Right out of the gate I stumble over the first line of code: window.indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB; window.indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;

Using Firebug I can see that window.indexedDB is undefined, as expected for FF 15, window.webkitIndexedDB is undefined as expected (FF is not webkit), but window.mozIndexedDB is null but not undefined. If it is null, which tells me that it exists but does not have a valid value / is not initialized.

This is from Firefox 15.0.1 on OSX 10.6.8 and Ubuntu 12.04. Can someone tell me why I cannot see / use window.mozIndexedDB ? Am I doing something wrong?

For completeness, here is my JavaScript file:

 window.indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB; var request = window.indexedDB.open("MyTestDatabase", 3); var db; request.onerror = function (event) { alert("Oops, request.onerror"); }; request.onsuccess = function (event) { // Do something with request.result! alert("Made it to request.onsuccess"); db = request.result; }; // This event is only implemented in recent browsers request.onupgradeneeded = function (event) { alert("Made it to request.onupgradeneeded"); }; db.onerror = function (event) { alert("Database error (db.onerror): " + event.target.errorCode); }; 
+4
source share
1 answer

My original HTML5 application uses jQuery Mobile and REST WS. In development, I would run it directly from the file system, and it works great. For sharing with colleagues, it works for me for Apache httpd.

When adding IndexedDB, I tried to test by viewing files from the file system through a browser. This did not help, and it made me go back to the square and try to run the sample code from Mozilla.

IndexedDB seems to require a domain, even if it is localhost. I just put my code under public_html and looked through it via httpd / localhost and it works fine.

0
source

Source: https://habr.com/ru/post/1438282/


All Articles