I use html2canvas library to make a png image of a table.
It works on Chrome, Firefox and Safari.
The code is as follows:
$('#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);
}
});
When I open the page with IE8 the page does not work.
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]-->
So, when I open the page with IE8, the library flashcanvas.js was loaded!
But the problem remains! IE8 tells me:
"The object does not support the property or the method 'toDataURL'"
Can anyone help me?
I’m not sure how the
canvas
element is created, but you might need to do something like this inside theonrendered
callback:See the docs here: http://flashcanvas.net/docs/usage