Html2Canvas仅在IE9中不起作用 [英] Html2Canvas not working in IE9 only

查看:137
本文介绍了Html2Canvas仅在IE9中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动打印div区域.所以我用过Html2Canvas.它可以在除IE9之外的所有浏览器中完美运行.如果有任何错误,请更正我的代码

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);
} 

推荐答案

此代码在所有浏览器中均能正常工作.

This code works fine in all browser.

html2canvas([document.getElementById(divName)], { 
 onrendered: function (canvas) { 
   var imageData= canvas.toDataURL('image/png',1.0);
 } 
});

这篇关于Html2Canvas仅在IE9中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆