Cross Origin Resource Sharing Headers not working

2019-03-29 16:26发布

问题:

I'm using rackspace to host my image files that are drawn on an html5 canvas object. Because of an HTML security feature when saving a canvas I have to use CORS (Cross Origin Resource Headers) to make save work.

I have tested my code on Chrome, IE with Chrome Frame, and Firefox, and none of them give me a security error after I added to the image request headers:

Access-Control-Allow-Origin: * 

and I have added the following attribute to all the images drawn on to the canvas

crossOrigin = "anonymous"

However, for some reason Safari still gives a security error.

SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent.

Any thoughts as to why this is happening on safari(desktop 5.1.7, and ipad) versions? I have checked the documentation and everything I have read says that Safari 4+ supports CORS?

回答1:

Safari 5.2 in beta solves the problem. So it looks like Safari does not yet support cors for images in released versions. The same goes for iOS safari