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