In chrome, all the rules in Firefox

openDatabase is not defined

Googled this article https://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/

How much I understood FF does not want to support Sql?

Error code on FF

try { var db = openDatabase('chatDb', '1.0', 'Db client', 5 * 1024 * 1024); db.transaction(function (t) { t.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id UNIQUE, log)'); //t.executeSql("DROP TABLE CHAT"); t.executeSql("CREATE TABLE IF NOT EXISTS CHAT ('id' INTEGER PRIMARY KEY ASC, 'name', 'message','groupe_all' TINYINT(1))"); }); db.transaction(function (t) { t.executeSql("SELECT * FROM CHAT", [], function (t, result) { for (var i = 0; i < result.rows.length; i++) { console.log(result.rows.item(i)); } }, null); }); } catch (exp) { //console.log(exp); } 
  • I did not see something where in the article it is written that FF does not want to support sql ? Everything works there, only the index DB is called - Alexey Shimansky
  • @ Alexey Shimansky, then why the mistake? about what he does not want to read on other resources - Serge Esmanovich
  • Show the code you are doing. But in general, I can guess right now. You are trying to work with indexedDB , like with webSQL , using the same methods, or even think that this is the same thing. And these are completely different bases. In chrome, a new opera (which is on the webkite), safaris have to work with webSQL , and in farfox indexedDB is used, in which the working methods are slightly different - Alexey Shimansky
  • I’ll probably make it easier for FF to request the archive of messages from Chrome =) it will be a little dumber to work in FF, but oh well - Serge Esmanovich

1 answer 1

openDatabase is not defined displayed because Firefox decided not to implement webSQL storage. Accordingly, the methods, functions, etc. that work with webSQL gives an error in FF .

To work with local storage, FF offers an alternative to IndexedDB . And appropriate methods for working with him. How to work with him can be found here or in the link that you wrote. It also clearly describes what there is a difference and gives examples of the difference in access to the base, its creation and so on.

In general, to work with local storage, if you want to work in chrome and fox, etc., in an amicable way, you need to make, for example, two files: webSQL.js and IndexedDB.js in which the operation logic will be described separately with one or another base.

When initializing the page where it is supposed to work with the repository, make a check on the browser. Depending on the browser to connect this or that script.

Browsers that support this or that kind of local storage can be viewed here:

http://caniuse.com/#feat=sql-storage

and here:

http://caniuse.com/#feat=indexeddb