Html2canvas.js reported an error

clipboard.png

 

obtained base64 content for data:,
on the Internet to find a lot, did not find a solution!


I have never encountered such a situation, so I searched it:

https://www.v2ex.com/t/455984

https://github.com/niklasvh/h...


I can try it with your js: codepen example

can you also post the html? And what is the version of html2canvas?


here comes the answer!
Thank you!

the old version introduced, the version number is html2canvas 0.4.1

here is the execution method!

$(document).ready(function () {
    var imgBlob = "";
    event.preventDefault();
    html2canvas(document.getElementById("demo"), {
        allowTaint: false,
        taintTest: true,
        logging: true,
        useCORS: true,
        background: "-sharpfff",
        onrendered: function (canvas) {
                imgBlob = canvas.toDataURL('image/jpeg', 1.0);
                imgBlob = imgBlob.toString().substring(imgBlob.indexOf(",") + 1);
                imgBlob = 'data:image/jpeg;base64,' + imgBlob;
                $('-sharptext').text(imgBlob);
            }
    })
});
Menu