Reputation: 23
when I try to use file saver and html2canvas it show that error, How to fix this ?
Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
$( "#click" ).on( "click", function() {
html2canvas(document.querySelector("#Views")).then(canvas => {
canvas.toBlob(function(blob) {
window.saveAs(blob, 'img.jpg');
});
});
});
Upvotes: 1
Views: 2585
Reputation: 136708
This error means that the call to HTMLCanvasElement#toBlob()
failed, this can happen for a couple of reasons:
height
or width
set to 0
:document.querySelector("canvas").toBlob(console.log);
<canvas width="0">
document.querySelector("canvas").toBlob(console.log);
<canvas width="80000" height="80000">
So you should check your element's computed style, taking particular attention to its size, but also to its display
value, since this problem is quite frequently caused by targeting an element with display: none
.
Upvotes: 2