【发布时间】:2013-01-25 05:48:27
【问题描述】:
我正在编写一个应用程序,用户可以在其中上传图像、绘制图像并保存结果。我试图通过使用画布元素并使用上传的图像作为其背景来实现这一点。我正在通过 ImageService 检索图像。下面是初始化画布的客户端代码:
var image = new Image();
image.src = "http://some.google.domain.com/foobar123";
var ctx = canvas.getContext('2d')
image.onload = function() {
ctx.drawImage(image, 0, 0);
};
现在用户可以在图像上绘制东西了。
然后当用户想要保存图片时,我调用:
canvas.toDataURL("image/png")
这会在 Chrome 中出现此错误:
Error: SecurityError: DOM Exception 18.
"Error: An attempt was made to break through the security policy of the user agent."
我假设 Chrome 不喜欢它,因为图像是从某个谷歌域提供的,这与我的应用引擎应用的域不同。
有解决办法吗?
提前致谢。
【问题讨论】:
-
通过您的服务器传递请求。
标签: javascript html google-app-engine google-chrome