'Html2Canvas: take screenshot of "Hello"
Trying to figure out why this is not working, it should take a screenshot of "Hello" onload but isn't doing anything?
<html>
<body>
<script src="html2canvas.js">
window.onload = function(){
html2canvas(document.body, {
onrendered: function(canvas) {
document.body.appendChild(canvas);
},
width: 300,
height: 300
})};
</script>
</body>
<h1>Hello</h1>
<canvas id="canvas" width="300" height="300" style="border:1px solid #d3d3d3;">
</html>
Solution 1:[1]
Try this:
<html>
<body>
<script src="html2canvas.js">
window.onload = function(){
html2canvas(document.body, {
onrendered: function(canvas) {
document.body.appendChild(canvas);
},
width: 300,
height: 300
})};
</script>
<h1>Hello</h1>
<canvas id="canvas" width="300" height="300" style="border:1px solid #d3d3d3;">
</body>
</html>
Move your canvas and h1 tags within the <body> and </body> tags.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vinzee |
