我使用html2canvas库来生成表的png映像。
它适用于Chrome、Firefox和Safari。
守则如下:
$('#myTable').html2canvas ({
onrendered : function(canvas) {
var img = canvas.toDataURL('image/png');
var newWin = window.open('', '_blank','width=500,height=400');
var htmlPage = "";
htmlPage += "<html>";
htmlPage += "<head>";
...
htmlPage += "</head>";
htmlPage += "<body>";
...
htmlPage += "<img src='"+img+"' width='400px'/>";
...
htmlPage += "</body>";
htmlPage += "</html>";
newWin.document.write(htmlPage);
}
});当我用IE8打开页面时,页面不工作。
我读过应该使用闪存画布,所以我添加了闪存画布库,并在页面中添加了此行:
<!--[if lt IE 9]>
<script type="text/javascript src="../sample/flashcanvas.js"></script>
<![endif]-->所以,当我用IE8打开页面时,就加载了库flashcanvas.js!
但问题依然存在!IE8告诉我:
"The object does not support the property or the method 'toDataURL'"有谁可以帮我?
发布于 2012-12-14 09:13:00
我不确定canvas元素是如何创建的,但是您可能需要在onrendered回调中执行如下操作:
if (typeof FlashCanvas != "undefined") {
FlashCanvas.initElement(canvas);
}
var img = canvas.toDataURL('image/png');
// etc...见这里的文档:http://flashcanvas.net/docs/usage
https://stackoverflow.com/questions/13875498
复制相似问题