用html2canvas在HTML5下将网页生成图片
html2canvas可以获取页面的DOM元素,将其生成图片,示例代码如下:
html2canvas(document.body, {
allowTaint: true,
aintTest: false,
onrendered: function(canvas) {
var img = canvas.toDataURL();
var newImg = document.createElement("img");
newImg.src = img;
document.body.appendChild(newImg);
}
}