0

Canvas2Image giving error in IE11. I am getting an error as

Object doesn't support this action

in Canvas2Image.js at line

var event = new MouseEvent('click',{"bubbles":false, "cancelable":false});

2 Answers2

0

I.E has problem with MouseEvents in some cases.

as a work around you could use something like below

var event = document.createEvent("MouseEvent");
event.initMouseEvent("click",false,false,window,0,0,0,0,0,false,false,false,false,0,null);

so your logic with fallback IE logic would be like below.

if (typeof MouseEvent !== 'function') {
    var event = document.createEvent("MouseEvent");
    event.initMouseEvent("click", false, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
} else {
    var event = new MouseEvent('click',{"bubbles":false, "cancelable":false});
}
ngChaitanya
  • 435
  • 2
  • 8
  • So after adding above code i dont see any error in the console. But after that nothing is happening. – Chetna Gupta May 15 '18 at 11:50
  • @chetnagupta did you forget to put final function? I don't see anything code. – ngChaitanya May 15 '18 at 11:52
  • function saveFile (strData,filename) { var save_link = document.createElement('a'); save_link.href = strData; save_link.download = filename; if (typeof MouseEvent !== 'function') { var event = document.createEvent("MouseEvent"); event.initMouseEvent("click", false, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); save_link.dispatchEvent(event); } else { var event = new MouseEvent('click',{"bubbles":false, "cancelable":false}); save_link.dispatchEvent(event); }} – Chetna Gupta May 15 '18 at 11:54
  • Looks like Canvas2ImageJS doesnt work in IE11 at all. i cant find any working demo in IE11 for the same. – Chetna Gupta May 15 '18 at 11:58
0

finally, I found solution in this link.

(I could success in IE11. using with html2canvas.js v0.41(old version) )

https://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=79712&sca=&sfl=wr_subject%7C%7Cwr_content&stx=%BF%DC%BA%CE+%C0%CC%B9%CC%C1%F6&sop=and

enter image description here

  • Does the download work in IE with html2canvas.js v0.41 ?? looks like it still doenst work for me – Chetna Gupta May 21 '18 at 10:17
  • Download happens in IE but the graphs disappear.Only text available is captured in the screenshot and we see white patches in place of charts/graphs – Chetna Gupta May 22 '18 at 10:11