通过Javascript进行SQLite调用时Firefox中出现错误 [英] Error in Firefox when making SQLite calls via Javascript

查看:59
本文介绍了通过Javascript进行SQLite调用时Firefox中出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在Chrome/Safari中完全运行的网站,并且非常依赖SQLite来存储/访问数据.但是,在Firefox中进行测试时,它在第一个调用openDatabase()时出错.这是我相当标准的openDB函数:

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, openDatabase(). This is my fairly standard openDB function:

function openDB(){
try {
    if (!window.openDatabase) {
        alert('not supported');
    } else {
        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.
    }
} catch(e) {
    // Error handling code goes here.
    if (e == 2) {
        // Version number mismatch.
        alert("Invalid database version.");
    } else {
        alert("Unknown error "+e+".");
    }
    return;
}

}

就像我说的那样-当我警告openDatabase时,它是未定义的,并且打印的未知错误是不受支持的".我以为Firefox实际上支持SQLite,是我做错了事还是需要特定于浏览器的代码?

Like I said - openDatabase is undefined when I alert it, and the Unknown error that prints is "unsupported". I assume SQLite is actually supported in Firefox, am I doing something wrong or does it require browser-specific code?

谢谢! 克劳迪娅

推荐答案

Firefox没有该功能. Mozilla认为SQLite不适合用于Web,因此在Firefox 4中,他们将选择并实施IndexedDB规范. W3C撰写的草案(包括Mozilla的提案).这是一篇很好的博客文章,详细介绍了这些区别: http://hacks.mozilla .org/2010/06/comparing-indexeddb-and-webdatabase/

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/

因此,是的,至少在其他主流浏览器中实现IndexedDB之前,您必须使用客户端特定的代码才能支持FF4.对于FF4之前的任何版本,不支持任何客户端数据库(不计算localStorage等).

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.).

这篇关于通过Javascript进行SQLite调用时Firefox中出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆