html2canvas
html2canvas copied to clipboard
Uncaught (in promise) Unable to find element in cloned iframe
How can I fix this error?
my example code:
const wrapper = document.createElement("div");
const myHTMLString = "<div>Hello</div>";
wrapper.insertAdjacentHTML("afterbegin",myHTMLString);
//console.log(">>>",wrapper);
html2canvas(wrapper,{useCORS: true}).then((canvas) => {
wrapper.appendChild(canvas);
console.log("canvas>>",wrapper.appendChild(canvas));
var base64encodedstring = canvas.toDataURL('image/jpeg', 1.0);
console.log("base6", base64encodedstring );
});
error : 176e275da87 1ms Starting document clone new:1 Uncaught (in promise) Unable to find element in cloned iframe
Having this issue too. you have to append the wrapper to the dom tree first:
document.body.appendChild(wrapper);
the canvas from the promise then does not contain a new canvas element, but an iframe containing it.
I also encountered the same problem. Have you solved it?
+1
+1
+1