移動端截圖外掛
阿新 • • 發佈:2018-12-26
移動端截圖外掛
本來想小程式用無奈,小程式不支援jq
<!DOCTYPE html>
<html>
<head >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML5實現網頁截圖</title>
<script src="http://cdn.bootcss.com/jquery/3.0.0-beta1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/html2canvas/0.5.0-beta4/html2canvas.js"></script>
<script>
function taoge(){
html2canvas($('#xttblog'), {
onrendered: function(canvas) {
// canvas 是最後一個渲染的<canvas> 元素
$('#btn').attr( 'href' , canvas.toDataURL() ) ;
$('#btn' ).attr( 'download' , 'xttblog.png' ) ;
}
});
}
</script>
</head>
<body>
<div id="xttblog">
<img src="http://www.xttblog.com/wp-content/uploads/2016/03/123.png"/>
<p>業餘草,做專業的IT學習交流網站</p>
<p>QQ群:135430763</p>
<p >原文地址:http://www.xttblog.com/?p=261</p>
<a href="" id="btn" onclick="taoge();">截圖</a>
</div>
</body>
</html>