我在Firefox中获得了完美的dataURI,但在Chrome中却没有。在Chrome中,它只是原始的空白画布。怎么了? (我需要在页面上生成图像)。
<html>
<head>
<script src="jquery-2.1.4.min.js"></script>
<script src="rasterizeHTML.allinone.js"></script>
</head>
<body>
<button id="run">Run!</button>
<div id="newcontent">Content example</div>
<canvas id="canvas" width="800" height="800" ></canvas>
<script>
$('#run').click(function(){
var canvas = document.getElementById("canvas");
var newcontent = document.getElementById("newcontent").innerHTML;
console.log(newcontent);
rasterizeHTML.drawHTML(newcontent, canvas);
var canvas = document.getElementById("canvas");
canvas.src = canvas;
canvas.crossOrigin = 'Anonymous';
var imgData = canvas.toDataURL();
console.log(imgData);
});
</script>
</body>
</html>