I'm working on a meme editor website using the html2canvas library from https://html2canvas.hertzen.com/
here is my html code for the div
that I need to capture:
<div class="container">
<div id="theUserMeme">
<div class="row">
<p id="memeWords">
When I see something lol
</p>
</div>
<div class="row">
<img id = "memeImage" src="images/init meme.jpg">
</div>
</div>
</div>
Also, this my JavaScript code that I run to capture the div
:
function generateMeme(){
window.scrollTo(0,0);
html2canvas(document.querySelector("#theUserMeme")).then(canvas => {
var image = canvas.toDataURL('image/jpeg', 1);
console.log(image);
alert(image);
document.getElementById("finalImageCopy").src = image;
});
}
After hosting the code on Github, I tried the page on my iPhone and my laptop. It was working well on both devices, but after that it is working on the phone only. When I use it on the desktop, the captured image isn't full and sometimes it is only white image.
What is the problem could be?