张鑫旭-鑫空间-鑫生活
it's my whole life!我的微码
IE浏览器不支持canvas toBlob()方法的Polyfill
2018-06-22 17:44
IE浏览器不支持canvas toBlob()方法的Polyfill,这里基于toDataURL()实现,直接粘贴在JS文件中即可。
相关文章:暂无
完整代码
if (!HTMLCanvasElement.prototype.toBlob) { Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', { value: function (callback, type, quality) { var canvas = this; setTimeout(function() { var binStr = atob(canvas.toDataURL(type, quality).split(',')[1]); var len = binStr.length, arr = new Uint8Array(len); for (var i = 0; i < len; i++ ) { arr[i] = binStr.charCodeAt(i); } callback(new Blob([arr], {type: type || 'image/png'})); }); } }); }
标签:JS
分享:新浪微博
评论
(0人参与,0条评论)