Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get a "Canvas has been tainted" error in Chrome but not in FF

I'm having a problem with my Javascript implementation. The script will run in Firefox but in Chrome it says:

Unable to get image data from canvas because the canvas has been tainted by cross-origin data. index.html:1
Uncaught Error: SecurityError: DOM Exception 18 

Does anyone have an idea of what the cause for such inconsistent behaviour could be?

like image 912
AndroidHustle Avatar asked Apr 25 '13 14:04

AndroidHustle


1 Answers

Chrome does not consider different local files to be sourced from the same domain. That is, each local file you reference via a file:// URL is treated as if it comes from a unique domain separate from that of other file:// URLs. That they're in the same directory makes no difference.

You can start Chrome with an option ("--allow-file-access-from-files" I think) that tells it to treat local files as all being from a common domain.

like image 152
Pointy Avatar answered Nov 10 '22 02:11

Pointy