Blob和BlobBuilder未定义

时间:2016-03-23 12:11:55

标签: javascript jquery browser safari blob

Blob中的BlobBuilderundefined都是safari browser version(5.1.4)。

我使用了现有的jsfiddle示例:

var array = new Int8Array([17, -45.3]); 
try{
  var jpeg = new Blob( [array], {type : "image/jpeg"});
}
catch(e){
    // TypeError old chrome and FF
    window.BlobBuilder = window.BlobBuilder 
                        || window.WebKitBlobBuilder 
                        || window.MozBlobBuilder 
                        || window.MSBlobBuilder;
    if(e.name == 'TypeError' && window.BlobBuilder){
        var bb = new BlobBuilder();
        bb.append([array.buffer]);
        var jpeg = bb.getBlob("image/jpeg");
    }
    else if(e.name == "InvalidStateError"){
        // InvalidStateError FF13 WinXP
        var jpeg = new Blob( [array.buffer], {type : "image/jpeg"});
    }
    else{
        // We're screwed, blob constructor unsupported entirely   
    }
}
alert(jpeg);

如何替换,请建议。

0 个答案:

没有答案