Skip to content Skip to sidebar Skip to footer

Error In Firefox When Making Sqlite Calls Via Javascript

I have a site that is fully functioning in Chrome/Safari and heavily relied on SQLite to store/access data. However, when testing in Firefox, it errors on the first call, openDatab

Solution 1:

Firefox doesn't have that feature. Mozilla doesn't think SQLite is appropriate for the web, so in Firefox 4 they will be instead opting for and implementing the IndexedDB spec. draft by the W3C (incl. proposals by Mozilla). Here's a nice blog post detailing the differences: http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/

So yes, you will have to use client specific code in order to support FF4 - at least until IndexedDB is implemented in the other major browsers. For anything before FF4, there is no support for any client database (not counting localStorage, etc.).

Solution 2:

It should be:

if (typeof(window.openDatabase)=='undefined') {
  alert(...)

Solution 3:

functionopenDB(){
try {
    if (!!window.openDatabase) {
        var shortName = 'tales';
        var version = '1.0';
        var displayName = 'Tall Tales Database';
        var maxSize = 65536; // in bytes
        db = openDatabase(shortName, version, displayName, maxSize); 
        // You should have a database instance in db.
    } else {
        alert('not supported');
    }
} catch(e) {
    // Error handling code goes here.if (e == 2) {
        // Version number mismatch.alert("Invalid database version.");
    } else {
        alert("Unknown error "+e+".");
    }
    return;
}

That should work.

Post a Comment for "Error In Firefox When Making Sqlite Calls Via Javascript"