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

懵懂的女人 提交于 2020-07-18 10:42:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!