我的 Javascript 实现有问题。该脚本将在 Firefox 中运行,但在 Chrome 中它会显示:
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
有谁知道造成这种不一致行为的原因是什么?
最佳答案
Chrome 不认为不同的本地文件来自同一域。也就是说,您通过 file://
URL 引用的每个本地文件都被视为来自与其他 file://
URL 不同的唯一域。它们位于同一目录中没有区别。
您可以使用一个选项(我认为是“--allow-file-access-from-files
”)来启动 Chrome,告诉它把本地文件视为所有来自公共(public)域的文件。
关于javascript - 我在 Chrome 中收到 "Canvas has been tainted"错误,但在 FF 中没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16217521/