javascript Internet Explorer 错误:SCRIPT5009:ArrayBuffer 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16545286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 05:05:32  来源:igfitidea点击:

Internet Explorer Error : SCRIPT5009: ArrayBuffer is undefined

javascriptarraysinternet-explorerbrowser

提问by SalesforceQueries

I am receiving an error in internet explorer 9 and under which does not occur on other browsers. It's:

我在 Internet Explorer 9 中收到错误,在其他浏览器上不会发生。它的:

SCRIPT5009: 'ArrayBuffer' is undefined

SCRIPT5009: 'ArrayBuffer' 未定义

My code is as follows

我的代码如下

    var rawLength = raw.length;
    var array = new Uint8Array(new ArrayBuffer(rawLength));
    for(i = 0; i < rawLength; i++) {
           array[i] = raw.charCodeAt(i);
            }

The line which breaks is var array = new Uint8Array(new ArrayBuffer(rawLength));

断线是 var array = new Uint8Array(new ArrayBuffer(rawLength));

Does anyone know if there is a solution or workaround for this? I require my functionality to work in all browsers.

有谁知道是否有解决方案或解决方法?我需要我的功能在所有浏览器中工作。

回答by Ian

ArrayBufferisn't supported until IE10 (and I think this shows it: http://caniuse.com/typedarrays).

ArrayBuffer直到 IE10 才支持(我认为这表明:http: //caniuse.com/typedarrays)。

You can use a polyfill, and here's one: https://github.com/inexorabletash/polyfill/blob/master/typedarray.js

您可以使用 polyfill,这是一个:https: //github.com/inexorabletash/polyfill/blob/master/typedarray.js

Polyfill taken from: https://github.com/inexorabletash/polyfill

Polyfill 取自:https: //github.com/inexorabletash/polyfill