我正在尝试使用JavaScript捕获整个页面正文(包括用户填写的字段)的截图,但是html2canvas只能捕获当前窗口,即使我将高度设置为一个巨大的数字。Html2canvas网站示例似乎具有我想要的功能,但我无法理解它们在做什么不同。
<button id="pdfbutton" type="button">Click Me!</button>
<script type="text/javascript">
$( "#pdfbutton" ).click(function() {
html2canvas(document.body, {
onrendered: function(canvas) {
// document.body.appendChild(canvas);
var img = canvas.toDataURL("image/png");
console.log(img);
document.body.appendChild(canvas);
}
// height: 10000
});
});
</script>
请告诉我有没有其他方法可以在JavaScript中通过按钮点击来截取屏幕截图(不插入URL,因为用户会填写我的页面上的字段)。