0
我从小提琴中获得了一个代码(http://jsfiddle.net/8ypxW/3/),用于将div转换为图像。 但是当我试图在我的网页它不工作.. 下面是我的代码....将div保存到图像(不工作)
plz帮助我的朋友实现.......
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(function() {
$("#btnSave").click(function() {
html2canvas($("#widget"), {
onrendered: function (canvas) {
theCanvas = canvas;
document.body.appendChild(canvas);
// Convert and download as image
Canvas2Image.saveAsPNG(canvas);
$("#img-out").append(canvas);
}
});
});
});
</script>
</head>
<body>
<span id="widget" class="widget">
this is text.
</span>
<br/>
<button id="btnSave">Save PNG</button>
<div id="img-out"></div>
</body>
</html>
由于现在它的工作....但在小提琴..他们力包括任何文件....所以我认为这将无需增加额外的文件 –
的小提琴也包括他们的工作。在左边查找'外部资源',这将列出任何外部资源与CSS文件或js文件。 –
ohhhh非常感谢.... :) –