HTML5 Canvas截图保存到页面上?

时间:2014-11-22 19:32:45

标签: javascript html html5 html5-canvas screenshot

我已经看过所有帖子,解释了如何将HTML5画布截图保存为图像并在新标签中打开该图像。但是,我希望获取该屏幕截图,并在截屏后将图像显示在SAME WEBPAGE上已分配的div中。有任何想法吗?谢谢!

1 个答案:

答案 0 :(得分:0)

<canvas id="mycanvas"></canvas>
<div id="under_canvas"></div>
<script>
var canvas = document.getElementById('mycanvas');
var img = canvas.toDataURL("image/png");
//dataURL can directly be inserted into src of image
document.getElementById('under_canvas').innerHTML = '<img src="'+img+'"/>';
</script>