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

后端 未结 10 1638
天涯浪人
天涯浪人 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条回答
  •  -上瘾入骨i
    2020-11-22 13:51

    You can't put spaces in your ID

    Update

    My guess is that image is on a different server than where you're executing the script. I was able to duplicate your error when running it on my own page, but it worked fine the moment I used an image hosted on the same domain. So it's security related - put the image on your site. Anyone know why this is the case?

提交回复
热议问题