Why does canvas.toDataURL() throw a security exception?

后端 未结 10 1645
天涯浪人
天涯浪人 2020-11-22 12:56

Did I not get enough sleep or what? This following code

var frame=document.getElementById(\"viewer\");
frame.width=100;
frame.height=100;

var ctx=frame.getC         


        
10条回答
  •  耶瑟儿~
    2020-11-22 13:38

    I had the same problem and all the images are hosted in the same domain... So, if someone is having the same problem, here is how I solved:

    I had two buttons: one to generate the canvas and another one to generate the image from the canvas. It only worked for me, and sorry that I don't know why, when I wrote all the code on the first button. So when I click it generate the canvas and the image at the same time...

    I always have this security problem when the codes were on different functions... =/

提交回复
热议问题