Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#mydiv {
background-color: lightblue;
width: 200px;
height: 200px
}
<div id="mydiv">
<img src="/img/logo-white.png" />
<p>text hhhh!</p>
</div>
<br><br>
<h2 id="link"></h2>
html2canvas([document.getElementById('mydiv')], {
onrendered: function(canvas) {
document.body.appendChild(canvas);
var data = canvas.toDataURL('image/png');
// AJAX call to send `data` to a PHP file that creates an image from the dataURI string and saves it to a directory on the server
document.getElementById('link').innerHTML=data;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment