【发布时间】:2014-12-03 18:31:38
【问题描述】:
我试图让我网站上的用户按下按钮来截取当前屏幕的屏幕截图(正文中的所有内容)。
根据我的研究,html2canvas 似乎是使这成为可能的资源。
我的问题是文档没有提供示例代码,我正在努力掌握所涉及的步骤。
http://html2canvas.hertzen.com/documentation.html
以下 SO 问题 (How to upload a screenshot using html2canvas?) 让我有些困惑。我现在只想知道如何获取图像。
来自他的代码。
$(window).ready(function(){
('body').html2canvas();
var canvasRecord = new html2canvas(document.body).canvas;
//At this point does the .toDataURL method return a png?
});
此时我不知道图像在哪里,甚至不知道如何/何时创建它。我会担心稍后将其发送到服务器。
任何信息表示赞赏。谢谢! (甚至需要html2canvas?)
【问题讨论】:
-
您可能还想考虑一些基于 phantomjs 的屏幕截图解决方案。查看on the PhantomJS wiki(搜索“屏幕截图”)或考虑this node.js/phantom project。
-
你可能想看看readme file的使用部分。
标签: javascript image screenshot html2canvas