SecurityError IE canvas.toDataURL(' image / png')相同的服务器

时间:2014-07-29 19:59:19

标签: javascript canvas svg cors data-uri

我认为这是一些关于CORS的常见问题,仅在IE(10或11)中。

发生我希望将图像从svg转换为png然后将其发送到要处理的服务器。

我正在使用saveSvgAsPng.js库,我编辑它以获取我的svg图像的dataUri为png:

      out$.svgAsPngDataUri = function(uri, cb) {
      //out$.svgAsDataUri(el, scaleFactor, function(uri) {
      var image = new Image();
      image.crossOrigin = "Anonymous";
      image.src = 'http://localhost/terepss/tmp/'+uri;//Uri is the name of the svg image
      image.onload = function() {
        var canvas = document.createElement('canvas');
        canvas.width = image.width;
        canvas.height = image.height;
        var context = canvas.getContext('2d');
        context.drawImage(image, 0, 0);

         if(cb) {
          cb(canvas.toDataURL('image/png'));//Here is the problem
         } 
      }
    //});
  };

正如您所看到的,image.src是localhost,与我的脚本相同,即使我将其更改为127.0.0.1或我的网络的IP 192.168.0.12,它也会抛出相同的内容。错误。

出了什么问题?

提前谢谢。

0 个答案:

没有答案
相关问题