问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/16217521/i-get-a-canvas-has-been-tainted-error-in-chrome-but-not-in-ff