0
我有一个网页,假设能够离线工作,并且当我在本地主机上并且没有互联网连接时,它完美无缺。当我将我的页面托管在我的服务器上并脱机运行(断开互联网)时,它会引发错误。未被捕获的错误:NotFoundError:DOM IDBDatabase异常8(离线)
Uncaught Error: NotFoundError: DOM IDBDatabase Exception 8
request.onsuccess
我不知道它为什么这样做。它可以正常工作,当我有互联网连接。我在Firefox和ie10在线和离线测试,它很好。它并没有破坏代码,一切仍然正常,它只是抛出了错误,并没有得到我刷新/加载页面时呈现的数据。这里是它抱怨的地方。
var version = 1;
var request = window.indexedDB.open(webDB.currentProperty, version);
request.addEventListener('blocked', function() { console.log('blocked'); });
console.log(webDB.currentProperty);
request.onsuccess = function (event) {
webDB.database = request.result;
// make transactiona reference to the database with read option (read is the
default option when none is provided)
var transaction = webDB.database.transaction([webDB.currentProperty]);
// hide or show elements after data has been populated
transaction.oncomplete = function() {
console.log("complete");
};
//Get the objectstore (conatains all the object) to do things
var objectStore = transaction.objectStore(webDB.currentProperty);
我检查了我的chrome版本,它是28,我检查是否在打开数据库时遇到阻塞,但我没有。
编辑
当我明确地给它一个只读选项
var transaction = webDB.database.transaction([webDB.currentProperty], "read-only");
,它抛出一个错误类型
Uncaught TypeError: Type error
request.onsuccess
〔这里(https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB)它说,它是只读的,读写和版本的变化。我知道它webDB.currentProperty作品,因为我检查它只包含字母数字字符。就像我上面说过的,当我连接互联网时,它工作得很好,但是一旦我接受它,它就会抛出错误。但它仍然有效,在页面上做些东西并刷新它后,它就会消失。 –