canvas.toDataURL() gives “Security Error” in IE 11

﹥>﹥吖頭↗ 提交于 2019-11-28 10:34:19

I was trying to export pdf of page which includes highcharts. I was getting same problem with IE when trying to load svg data on canvas, same security error.

I fixed this issue using canvg.js

just include canvg library files,

Add canvas on html page,

<canvas id="canvas" width="1000px" height="600px"></canvas> 

use below method,

canvg(document.getElementById('canvas'), xml);

It worked for me in all browsers including IE.

By using fabric js "Security Error" in IE 11 will be gone.

    var
        imgData,
        width = media.videoWidth,
        height = media.videoHeight,
        canvas = document.createElement("canvas"),
        fabCanvas  = new fabric.Canvas('c'),
        context = fabCanvas.getContext('2d');

    canvas.width = width;
    canvas.height = height;

    fabCanvas.fillRect(0, 0, width, height);
    fabCanvas.drawImage(media, 0, 0, width, height);

    imgData = fabCanvas.toDataURL({format: "png"});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!