Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Webextension DataView构造函数不工作_Javascript_Firefox Addon Webextensions - Fatal编程技术网

Javascript Webextension DataView构造函数不工作

Javascript Webextension DataView构造函数不工作,javascript,firefox-addon-webextensions,Javascript,Firefox Addon Webextensions,我正在使用Firefox 50.1.0。我创建了以下web扩展: manifest.json { "content_scripts": [ { "matches": ["http://exifdata.com/"], // sample site "js": ["index.js"] } ], "manifest_version": 2, "name": "Test", "version": "0.0.0" } index.js fu

我正在使用Firefox 50.1.0。我创建了以下web扩展:

manifest.json

{
  "content_scripts": [
    {
      "matches": ["http://exifdata.com/"], // sample site
      "js": ["index.js"]
    }
  ],
  "manifest_version": 2,
  "name": "Test",
  "version": "0.0.0"
}
index.js

function fileToDataView(file) {
  var reader = new FileReader();
  reader.onload = function (e) {
    console.log(new DataView(e.target.result)); // empty Dataview
  };
  reader.onerror = function (error) {
    console.log(error); // no error occurs
  };
  reader.readAsArrayBuffer(file);
}

var nodes = document.querySelectorAll('input[type=file]')

nodes.forEach(function (node) {
  node.onchange = function (event) {
    fileToDataView(event.target.files[0]);
  }
})
上载文件时,会调用函数
fileToDataView

在此函数中,reader.onload记录
new DataView()
,但它是一个空的DataView对象,而不是带有参数
e.target.result的DataView

我做错了什么?问题是我想在之后调用
.getInt8()
,但抛出的错误
不是函数


完整的代码是。

恐怕这只是Firefox中的一个例子。我正在为Firefox54修复这个问题


如果您使用不同类型的Darrays来包装您的ArrayBuffer而不是DataView,它应该可以工作。

我担心这只是Firefox中的一个简单问题。我正在为Firefox54修复这个问题

如果使用不同类型的Darrays来包装ArrayBuffer而不是DataView,它应该可以工作