如何使用Javascript/JQuery拍摄当前网页的屏幕截图? [英] How to take screen shot of current webpage using Javascript/JQuery?
本文介绍了如何使用Javascript/JQuery拍摄当前网页的屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用JavaScript/JQuery拍摄网页的屏幕截图.您能解释一下我需要遵循的代码步骤吗?
I was trying to take screen shot of a web page using JavaScript/JQuery. Could you please explain me the code steps I need to follow?
推荐答案
html2canvas2 JavaScript实用程序适用于截取以下内容的屏幕截图一个网页.您必须使用三个JavaScript库:
The html2canvas2 JavaScript utility is suitable to take a screenshot of a webpage. You have to use three JavaScript libraries:
1.jquery-1.10.2.min.js
2.html2canvas.js
3.jquery.plugin.html2canvas.js
然后调用函数capture(),它将在新窗口中为您提供基于HTML5画布的屏幕截图.它还生成image的base64data值.它仅在支持HTML5 canvas的浏览器中起作用.
Then call the function capture(), which will give you an HTML5 canvas-based screenshot in new window. It also generates a base64data value of image. It only works in browsers that support HTML5 canvas.
<script type="text/javascript">
function capture() {
html2canvas($('body'),{
onrendered: function (canvas) {
var imgString = canvas.toDataURL("image/png");
window.open(imgString);
}
});
</script>
这篇关于如何使用Javascript/JQuery拍摄当前网页的屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文