HTML5画布getImageData和同源策略

我有一个在pixie.strd6.com上运行的网站和通过Amazon S3托管的图像,其中包含一个CNAME for images.pixie.strd6.com.

我想能够将这些图像绘制到HTML5画布上,并调用getImageData方法,但会抛出错误:SECURITY_ERR:DOM异常18

我已经尝试设置window.domain =“pixie.strd6.com”,但这没有任何效果.

另外,$.get(“http://dev.pixie.strd6.com/sprites/8516/thumb.png?1293830982”,function(data){console.log(data)})也会引发一个错误:XMLHttpRequest不能负载http://dev.pixie.strd6.com/sprites/8516/thumb.png?1293830982.原点http://pixie.strd6.com不允许由Access-Control-Allow-Origin.

理想情况下,HTML5 canvas不会阻止从子域调用getImageData.我已经在S3中设计了一个Access-Control-Allow-Origin标头,但是还没有成功.

任何帮助或解决方法非常感谢.

解决方法

Amazon recently announced CORS support

We’re delighted to announce support for Cross-Origin Resource Sharing (CORS) in Amazon S3. You can now easily build web applications that use JavaScript and HTML5 to interact with resources in Amazon S3,enabling you to implement HTML5 drag and drop uploads to Amazon S3,show upload progress,or update content. Until now,you needed to run a custom proxy server between your web application and Amazon S3 to support these capabilities.

How to enable CORS

To configure your bucket to allow cross-origin requests,you create a CORS configuration,an XML document with rules that identify the origins that you will allow to access your bucket,the operations (HTTP methods) will support for each origin,and other operation-specific information. You can add up to 100 rules to the configuration. You add the XML document as the cors subresource to the bucket.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


h5页面是什么意思
html5复合选择器都有哪些
什么是html5响应式布局
h5页面制作策划怎么做
html5关系选择器有哪些
h5有哪些缓存机制
position中的sticky如何使用
h5页面制作用什么软件
h5链接怎么做
html5层次选择器有哪些
h5是什么意思
localstorage有哪些方法
h5怎么制作点击图标
h5怎么制作倒计时
h5怎么生成链接
h5表格边框怎么设置
h5兼容问题怎么解决
h5怎么做交互设计
h5怎么做进度条
h5怎么加链接