JS中的子域之间的“跨源资源共享策略”?

问题描述:

我有一个Tumblr主题,包括画布脚本。

跨源资源共享策略不允许 context.getImageData()工作。脚本位于 user.tumblr.com

图片位于 static.tumblr.com

I have a Tumblr theme that includes a canvas script.
The Cross-Origin Resource Sharing policy doesn't allow context.getImageData() to work. Script is located at user.tumblr.com,
images are located at static.tumblr.com.

这有什么解决方案吗?

谢谢!

document.domain 将成为您的朋友

我没有仔细研究画布安全模型,但如果遵循Javascript的其余部分,请设置

I haven't studied the canvas security model closely, but if it follows the rest of Javascript, setting

document.domain = tumblr.com

(对于document.domain画布,可能会导致更多。)

(Googling for document.domain canvas may lead to more.)