javascript - 无法在 Firefox 中打开 IndexedDB

标签 javascript firefox firefox-addon indexeddb

当我尝试从我的 firefox 扩展打开 indexeddb 时出现以下错误

[异常...“非法值”nsresult:“0x80070057(NS_ERROR_ILLEGAL_VALUE)”位置:“JS frame::chrome://extension/abc.html::openDb::line 213”数据:无]

const DB_NAME = 'dbName';
const DB_VERSION = 1; 
const DB_STORE_NAME = 'dbStore';

var db;

 function openDb() {
  try{
    var req = indexedDB.open(DB_NAME, DB_VERSION);
  req.onsuccess = function (evt) {
    db = this.result;
  };
  req.onerror = function (evt) {
   console.error("openDb:", evt.target.errorCode);
  };

  req.onblocked = function(evt) {
  // If some other tab is loaded with the database, then it needs to be closed
  // before we can proceed.
  console.log("Please close all other tabs with this site open!");
  alert("Please close all other tabs with this site open!");
  };
 }
catch(err){
    alert(err);
}
 }

它进入带有上述引用错误的 catch 部分。

提前致谢。

最佳答案

下面应该给出一个有效的 indexedDB

Components.utils.importGlobalProperties(["indexedDB"]);

我只测试了 open 是否返回有效的 IDBDatabase 对象。请确认数据存储和检索。

(这只是一个解决方法,indexedDB 访问器方法有问题)

编辑:Chrome 对话框有一个有效的 indexedDB

关于javascript - 无法在 Firefox 中打开 IndexedDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22956440/

相关文章:

javascript - 在后台暂停事件监听器

firefox - Greasemonkey 插件无法正常工作

javascript - RegExp.exec 在 Firefox 上的奇怪行为

javascript - 如何使用 confirm() 将整个网页更改为全屏?

javascript - 在内容脚本和主附加脚本之间传递 RegExp 对象

Javascript自定义应用函数

javascript - 用 javascript 绘制图表

javascript - 跨选项卡复制数据

javascript - 如何在 javascript/nodejs 中拆分包含 n 个连接的 json 字符串的字符串?

javascript - 使用 javascript 在 Firefox 附加组件中设置 <input type ="file"> 值