<bdo id='Xiwa4'></bdo><ul id='Xiwa4'></ul>

<tfoot id='Xiwa4'></tfoot>
  1. <small id='Xiwa4'></small><noframes id='Xiwa4'>

      <legend id='Xiwa4'><style id='Xiwa4'><dir id='Xiwa4'><q id='Xiwa4'></q></dir></style></legend>

      <i id='Xiwa4'><tr id='Xiwa4'><dt id='Xiwa4'><q id='Xiwa4'><span id='Xiwa4'><b id='Xiwa4'><form id='Xiwa4'><ins id='Xiwa4'></ins><ul id='Xiwa4'></ul><sub id='Xiwa4'></sub></form><legend id='Xiwa4'></legend><bdo id='Xiwa4'><pre id='Xiwa4'><center id='Xiwa4'></center></pre></bdo></b><th id='Xiwa4'></th></span></q></dt></tr></i><div id='Xiwa4'><tfoot id='Xiwa4'></tfoot><dl id='Xiwa4'><fieldset id='Xiwa4'></fieldset></dl></div>
    1. 为什么在 crossOrigin = 'Anonymous' 图像上设置 base64 数据时,Safa

      Why does Safari throw CORS error when setting base64 data on a crossOrigin = #39;Anonymous#39; image?(为什么在 crossOrigin = Anonymous 图像上设置 base64 数据时,Safari 会引发 CORS 错误?)
      • <bdo id='2YQRq'></bdo><ul id='2YQRq'></ul>

        1. <tfoot id='2YQRq'></tfoot>
          <i id='2YQRq'><tr id='2YQRq'><dt id='2YQRq'><q id='2YQRq'><span id='2YQRq'><b id='2YQRq'><form id='2YQRq'><ins id='2YQRq'></ins><ul id='2YQRq'></ul><sub id='2YQRq'></sub></form><legend id='2YQRq'></legend><bdo id='2YQRq'><pre id='2YQRq'><center id='2YQRq'></center></pre></bdo></b><th id='2YQRq'></th></span></q></dt></tr></i><div id='2YQRq'><tfoot id='2YQRq'></tfoot><dl id='2YQRq'><fieldset id='2YQRq'></fieldset></dl></div>

          <small id='2YQRq'></small><noframes id='2YQRq'>

            <tbody id='2YQRq'></tbody>

            1. <legend id='2YQRq'><style id='2YQRq'><dir id='2YQRq'><q id='2YQRq'></q></dir></style></legend>
                本文介绍了为什么在 crossOrigin = 'Anonymous' 图像上设置 base64 数据时,Safari 会引发 CORS 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我遇到一个问题,将图像 src(使用 new Image 创建的图像)设置为 base64 编码图像失败,原因是:跨域资源共享策略拒绝跨域图像加载.

                I'm having an issue where setting an image src (image created with new Image) to a base64 encoded image fails by throwing: Cross-origin image load denied by Cross-Origin Resource Sharing policy.

                我已经有 image.crossOrigin = 'Anonymous'了.

                请参阅以下代码笔:http://codepen.io/bedeoverend/pen/aORQzg.它适用于 Chrome,但不适用于 Safari.如果可以,黑白饼图图像应该会显示在底部.

                See the following codepen: http://codepen.io/bedeoverend/pen/aORQzg. It works in Chrome, but not in Safari. The black and white pie chart image should show up down the bottom if it worked.

                为什么会发生这种情况以及如何解决?

                Why does this happen and how can it be resolved?

                更新:

                为了澄清,我在这里做了一个更集中的代码笔:http://codepen.io/bedeoverend/pen/BNGarr

                To clarify, I've made a more focused codepen here: http://codepen.io/bedeoverend/pen/BNGarr

                似乎在图像上设置 crossOrigin = 'Anonymous' 然后在 Safari 中加载 base64 失败.在 Chrome 44 上,这两个文本都更改为 Worked...,但在 Safari 8.0.3 上,跨源匿名一个失败.在 Firefox 35 & 上也失败了39.

                It seems that setting crossOrigin = 'Anonymous' on an image then loading in base64 fails for Safari. Both text changes to Worked... on Chrome 44, but on Safari 8.0.3, the cross origin Anonymous one fails. Also fails on Firefox 35 & 39.

                所以现在的问题本质上是,为什么当图像的 crossOrigin 属性设置为匿名"时,Safari 无法加载 base64 图像?

                So the question is essentially now, why, when an Image's crossOrigin property is set to 'Anonymous', does Safari fail to load base64 images in?

                推荐答案

                MDN 声明您必须有一个服务器托管具有适当的 Access-Control-Allow-Origin 标头的图像."

                MDN states that "You must have a server hosting images with the appropriate Access-Control-Allow-Origin header."

                根据到规格,
                强调我的

                不幸的是,这可用于对用户的本地网络执行基本的端口扫描[...]用户代理可以实施更严格<的跨域访问控制策略/strong> 比上面描述的更能减轻这种攻击,但不幸的是,这些策略通常与现有的 Web 内容不兼容."

                This, unfortunately, can be used to perform a rudimentary port scan of the user's local network [...] User agents may implement cross-origin access control policies that are stricter than those described above to mitigate this attack, but unfortunately such policies are typically not compatible with existing Web content."

                您可以通过检查 url 字符串来简单地解决它,如果它以 data: 开头,那么它可能不会与跨源标头一起提供,那么您可以将 crossOrigin 属性设置回 null.

                You could simply workaround it by checking the url string, if it starts with data: then it probably won't be served with the cross origin header, then you can set the crossOrigin property back to null.

                这篇关于为什么在 crossOrigin = 'Anonymous' 图像上设置 base64 数据时,Safari 会引发 CORS 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))

                  • <legend id='ywCtZ'><style id='ywCtZ'><dir id='ywCtZ'><q id='ywCtZ'></q></dir></style></legend>

                    <small id='ywCtZ'></small><noframes id='ywCtZ'>

                  • <tfoot id='ywCtZ'></tfoot>
                    <i id='ywCtZ'><tr id='ywCtZ'><dt id='ywCtZ'><q id='ywCtZ'><span id='ywCtZ'><b id='ywCtZ'><form id='ywCtZ'><ins id='ywCtZ'></ins><ul id='ywCtZ'></ul><sub id='ywCtZ'></sub></form><legend id='ywCtZ'></legend><bdo id='ywCtZ'><pre id='ywCtZ'><center id='ywCtZ'></center></pre></bdo></b><th id='ywCtZ'></th></span></q></dt></tr></i><div id='ywCtZ'><tfoot id='ywCtZ'></tfoot><dl id='ywCtZ'><fieldset id='ywCtZ'></fieldset></dl></div>
                      <tbody id='ywCtZ'></tbody>
                      <bdo id='ywCtZ'></bdo><ul id='ywCtZ'></ul>