Javascript 标题“添加访问控制允许来源”*&引用;toDataURL不工作
这是我在Web服务器的images文件夹中的.htaccess文件中的内容Javascript 标题“添加访问控制允许来源”*&引用;toDataURL不工作,javascript,.htaccess,todataurl,Javascript,.htaccess,Todataurl,这是我在Web服务器的images文件夹中的.htaccess文件中的内容 # Do not remove this line, otherwise mod_rewrite rules will stop working RewriteBase /images Header add Access-Control-Allow-Origin "*" 我还使用以下行:img.crossOrigin='Anonymous'在我的JS文件中,但我仍然得到错误 Cross-origin image
# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /images
Header add Access-Control-Allow-Origin "*"
我还使用以下行:img.crossOrigin='Anonymous'代码>在我的JS文件中,但我仍然得到错误
Cross-origin image load denied by Cross-Origin Resource Sharing policy.
可在此处找到工作示例:
只需查看控制台中的错误
Cross-origin image load denied by Cross-Origin Resource Sharing policy.
将image src属性更改为img.src=”后,它将工作http://goo.gl/AOxHAL“
,但不适用于服务器上的图像。你知道为什么吗
编辑:我甚至试着在我的htaccess文件中使用它,但仍然会出现同样的错误
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch "\.(cur|gif|ico|jpe?g|png|svgz?|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
SetEnvIf原点“:”是
标题集访问控制允许原点“*”env=IS\u CORS
您是否在响应中看到返回的CORS标题?这是我在使用标题检查网站检查标题时看到的:Access Control Allow Origin=>*我如何才能在响应中看到返回的标题?