我有一个网页,它应该能够脱机工作,当我在本地主机上,没有互联网连接时,它会做得很好。当我在服务器上托管我的页面并脱机运行它(断开互联网)时,它会抛出一个错误。
Uncaught Error: NotFoundError: DOM IDBDatabase Exception 8
request.onsuccess我不知道它为什么要这么做。当我有网络连接的时候,它可以正常工作。我在火狐和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);我检查了我的铬版,它是28,我检查了一下我打开数据库时是否被阻塞了,但我没有。
编辑
当我明确地给它一个只读选项时
var transaction = webDB.database.transaction([webDB.currentProperty], "read-only");它引发类型错误。
Uncaught TypeError: Type error
request.onsuccess发布于 2013-07-27 04:57:06
https://stackoverflow.com/questions/17892680
复制相似问题