javascript - canvas toDataURL() cross-domain issue
淡淡烟草味
淡淡烟草味 2017-05-16 13:36:18
0
1
499

The picture is placed on Youpaiyun. When canvas calls the picture, todataURl will report an error in the end. Is there any solution?
Baidu also looked at many solutions but none of them could be implemented. .
Error message:

Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
淡淡烟草味
淡淡烟草味

reply all(1)
小葫芦

If it is new Image(), add the following settings:

// 引用外部图片,需设置 crossOrigin 属性,否则 toDataURL 调用异常
image.setAttribute('crossOrigin', 'anonymous');

Reference question: /q/10...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template