我收到“画布已被弄脏”的字样。 Chrome中出现错误,但FF中没有 [英] I get a "Canvas has been tainted" error in Chrome but not in FF
问题描述
我的Javascript实现存在问题。该脚本将在Firefox中运行,但在Chrome中显示:
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
任何人都有
推荐答案
Chrome浏览器不认为不同的本地文件来自同一本地文件域。也就是说,您通过 file://
URL引用的每个本地文件都被视为来自与其他文件不同的唯一域://
网址。它们在同一个目录中没什么区别。
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.
您可以使用一个选项启动Chrome( -allow-file-access- from-files
(我认为),它告诉它将本地文件视为全部来自公共域。
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.
这篇关于我收到“画布已被弄脏”的字样。 Chrome中出现错误,但FF中没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!