使用html2canvas 讲网页元素保存成图片
引用文件
<script src="dist/js/html2canvas.min.js"></script>
<script type="text/javascript" src="http://www.boolaw.com/tpl/default/js/jquery-1.8.3.min.js"></script>
HTML
<a type="button" id="down_button">download</a>
JS
$(function(){
print();
});
function print(){
html2canvas( $("#o_text") ,{
onrendered: function(canvas){
$('#down_button').attr('href',canvas.toDataURL());
$('#down_button').attr('download', '1.png' );
}
});
}
网友评论