我html2canvas
用来转换div
为image/png
. It works fine when there is a text in selected div
but I have an image in it. 因此,当我单击按钮时,我无法在创建的图像中看到base64
图像html2canvas
。
我的代码是这样的;
这是我的脚本:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="html2canvas.js"></script>
<script>
$(function(){
$('.savedraft').click(function(){
html2canvas([ document.getElementById('div2image') ],{
onrendered: function(canvas) {
window.open(canvas.toDataURL());
}
});
})
});
</script>
这是我的身体:
<div class="savedraft">Convert</div>
<div id="div2image" >
<img src="WebSite5/html2canvas-master/tests/assets/image_1.jpg" />
</div>