您可以使用HTML5 Canvas截取页面的屏幕截图吗?
Html2Canvas是一个JavaScript库,可以获取整个网页或特定部分的屏幕截图。它不需要屏幕截图,而是根据页面信息创建视图。
示例
下面给出的是示例代码。在这里,html2canvas.js脚本包含在<head>中。调用html2canvas()方法。返回base64值,该值最终创建图像源或图像文件。
<!DOCTYPE html>
<html>
<head>
<script src="html2canvas-master/dist/html2canvas.js"></script>
</head>
<body>
<h1>Take screenshot</h1>
<div class="container" id='container' >
<imgsrc='images/one.jpg' width='50' height='50'>
<imgsrc='images/two.jpg' width='50' height='50'>
</div>
<input type='button' id='but_screenshot' value='Take screenshot' onclick='screenshot();'><br/>
<script>
function screenshot(){
html2canvas(document.body).then(function(canvas) {
document.body.appendChild(canvas);
});
}
</script>
</body>
</html>热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短