E
E
Evgeny Nizamiev2014-06-29 12:11:20
JavaScript
Evgeny Nizamiev, 2014-06-29 12:11:20

How to get rid of "Tainted canvases may not be exported" error?

Chrome swears like this Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. on this line in the code
canvasImg = canvas.toDataURL("image/png");
I use html2canvas. An error occurs if the page is opened from some folder, if the page is uploaded to the server, then everything works fine there.
How to get rid of this error?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mark_slepkov, 2016-05-30
@mark_slepkov

< img crossorigin="anonymous" src=" some.url " /> Helpful

K
Konstantin Kitmanov, 2014-06-29
@k12th

Tainted canvas - a canvas on which a drawing from another domain is displayed. Some operations (for example, .toDataURL) with such a canvas are considered a violation of the same origin policy.
For a file opened locally, any other domain is considered a violation of the same origin policy, hence the error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question