本文介绍了替代IE10的readAsBinaryString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎 ,IE10中不支持JavaScript FileReader 对象的方法。我按照:

It seems that readAsBinaryString, a method of the JavaScript FileReader object, is not supported in IE10. I've tried the following, as suggested in this HTML5 Rocks article:

String.fromCharCode.apply(null, new Uint16Array(buffer));

然而,这导致堆栈空间不足错误。

推荐答案

我找到了答案:

var binary = "";
var bytes = new Uint8Array(buffer);
var length = bytes.byteLength;
for (var i = 0; i < length; i++) {
  binary += String.fromCharCode(bytes[i]);
}

这篇关于替代IE10的readAsBinaryString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-10 22:34