1

Firefox 13+ 支持 Blob,但是对于较低版本,有什么替代解决方案?

我有这段代码可以从 bsae64 字符串创建一个 blob:

    function base64ToBlob(base64) {
        var binary = $wnd.atob(base64);
        var len = binary.length;
        var buffer = new ArrayBuffer(len);
        var view = new Uint8Array(buffer);
        for ( var i = 0; i < len; i++) {
                view[i] = binary.charCodeAt(i);
        }
        var blob = new Blob([ view ]);
        return blob;
    };
    var newBlob = base64ToBlob(b64);
    var URLObj = window.URL || window.webkitURL;
    var source = URLObj.createObjectURL(newBlob);
    return source;

在较低版本的 Firefox 上运行它会抛出(TypeError): Blob is not a constructor

4

0 回答 0