Reputation: 339
I have updated html2canvas from 0.4 to 1.0.0 and I used the function below to take a screenshot.
The function and html2canvas does not work and I got the error below.
How do I solve it?
icefaces-compat.js.jsf?ln=ice.compat&v=3_3_0_130416:1 2ms html2canvas: onrendered option is deprecated, html2canvas returns a Promise with the canvas as the value
function screenshotChrome() {
var target = $(document.body);
html2canvas(target, {
useCORS: true,
onrendered: function (canvas) {
canvas.UniversalToBlob(function (blob) {
saveAs(blob, "aScreenshot.png");
},
"image/png", 1);
}
});
}
Upvotes: 0
Views: 7704
Reputation: 17361
I'm not familiar with the library, but the error says that this version uses a Promise
instead of using the onrendered
callback option. Therefore, it is (probably) used like:
html2canvas(target, {
useCORS: true
})
.then(function (canvas) {
canvas.UniversalToBlob(function (blob) {
saveAs(blob, "aScreenshot.png");
}, "image/png", 1);
})
.catch(function (err) { console.log(err); });
Upvotes: 7