AndroidHustle AndroidHustle - 5 months ago 32
Javascript Question

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?


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.