我正在开发一个chrome扩展程序,并且真的想让我的chrome选项页面访问IndexedDB中的数据,但似乎不支持这个?
错误为:
未捕获的TypeError:无法读取未定义的option.js:42
的属性'transaction' var request = indexedDB.open(DB_NAME, DB_VERSION);
//console.log(request); /* The created indexedDB can be checked */
request.onsuccess = function (evt) {
console.log("Database Open Successfully: " + evt);
db = this.result;
/* Get the initialised logIndex*/
var storeLog = db.transaction(DB_STORE1, 'readonly').objectStore(DB_STORE1);
var req = storeLog.openCursor(null, 'prev');
req.onsuccess = function (evt) {
console.log("Inner Successfully");
}
req.onerror = function(evt){
console.error("Inner error" + evt.target.errorCode);
}
};
request.onerror = function (evt) {
console.error("Database Error: " + evt.target.errorCode);
};
想知道是否可以在“chrome option_page”中访问IndexedDB
答案 0 :(得分:2)
对陈述的问题的简短回答是"是的,IndexedDB完全支持扩展页"。您的request.onsuccess
被解雇的事实就足以证明这一点。
您的问题似乎并非特定于Chrome扩展程序;我建议您查看一些IndexedDB教程like this one来调试代码。
请注意,您可能需要在清单中请求"unlimitedStorage"
权限才能存储大量数据。