IE2上的html2canvas和flashcanvas无法正常工作 [英] html2canvas and flashcanvas on IE8 not working
问题描述
我使用html2canvas库制作表格的png图像.
I use html2canvas library to make a png image of a table.
它可在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打开页面时,该页面无法正常工作.
我已经读到我应该使用flashcanvas,所以我添加了flashcanvas库并在页面中添加了此行:
I have read that I should use flashcanvas, so I added the flashcanvas library and added this row in the page:
<!--[if lt IE 9]>
<script type="text/javascript src="../sample/flashcanvas.js"></script>
<![endif]-->
因此,当我使用IE8打开页面时,库flashcanvas.js已加载!
So, when I open the page with IE8, the library flashcanvas.js was loaded!
但是问题仍然存在!IE8告诉我:
But the problem remains! IE8 tells me:
"The object does not support the property or the method 'toDataURL'"
有人可以帮助我吗?
推荐答案
我不确定如何创建 canvas
元素,但是您可能需要在内执行类似的操作渲染的
回调:
I’m not sure how the canvas
element is created, but you might need to do something like this inside the onrendered
callback:
if (typeof FlashCanvas != "undefined") {
FlashCanvas.initElement(canvas);
}
var img = canvas.toDataURL('image/png');
// etc...
在此处查看文档: http://flashcanvas.net/docs/usage
这篇关于IE2上的html2canvas和flashcanvas无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!