问题
I want to print div area automatically. So I have used Html2Canvas. It working perfectly in all browsers except IE9. Please correct my code if it has any bugs
function printSchedule() {
var browserName = '${sessionScope.BrowserContext.browserName}';
//console.log("browserName::"+browserName);
if(browserName != 'msie'){
$("#printArea").html2canvas();
}
else if(browserName == 'msie'){
var el = document.createElement('printArea');
G_vmlCanvasManager.initElement(el);
var ctx = el.getContext('2d');
}
setTimeout(function(){
window.print();
$('html').unblock();},6000);
}
回答1:
This code works fine in all browser.
html2canvas([document.getElementById(divName)], {
onrendered: function (canvas) {
var imageData= canvas.toDataURL('image/png',1.0);
}
});
来源:https://stackoverflow.com/questions/18459731/html2canvas-not-working-in-ie9-only