0

When I'm using the file in local c drive i got an error

(Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.) the url didnt generate thorows an error

$(document).ready(function(){
init();
$("#reset").bind("mousedown",resetClick)
});

function init(){
stage = new createjs.Stage("myCanvas");  //get the canvas in the stage 
my_map=new createjs.Bitmap('octopus_line.png'); //create the bitmap 

my_map.y=0;
my_map.x=0;
stage.addChildAt(my_map,2);
}


function resetClick(){
img = new Image();
img.crossOrigin="Anonymous";

//generate the url using toDataURL

canvas=document.getElementsByTagName("canvas")[0];
url=canvas.toDataURL("image/png").replace("image/png","image/octet-stream");  
img.src = url; 
download(img.src,"filename.png")
}
NoNaMe
  • 6,020
  • 30
  • 82
  • 110
hezaltin
  • 61
  • 1
  • 4
  • Maybe this thread is related to your question: [tainted-canvases-may-not-be-exported](http://stackoverflow.com/questions/22710627/tainted-canvases-may-not-be-exported) – andrrs Aug 12 '15 at 11:52
  • The OS is windows 7 only , i have tried in other drives to but it was given the same error. – hezaltin Aug 12 '15 at 14:58
  • 1
    The OS is entirely irrelevant. – Oliver Aug 12 '15 at 21:36
  • If you are doing this using cross-origin images, see if you can add CORS headers on them. The crossOrigin flag only works if the server sends a CORS header. If this is happening locally, perhaps run a local file server for testing, as it shouldn't happen on the server if all the assets are from the same domain. – Lanny Aug 13 '15 at 02:29

0 Answers0