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

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

          <bdo id='DoTVy'></bdo><ul id='DoTVy'></ul>
      1. 受污染的画布不得出口

        时间:2023-06-21

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

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

              1. <tfoot id='ybumK'></tfoot>

              2. <legend id='ybumK'><style id='ybumK'><dir id='ybumK'><q id='ybumK'></q></dir></style></legend>
                  <bdo id='ybumK'></bdo><ul id='ybumK'></ul>
                  本文介绍了受污染的画布不得出口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想将我的画布保存到 img.我有这个功能:

                  I want to save my canvas to a img. I have this function:

                  function save() {
                      document.getElementById("canvasimg").style.border = "2px solid";
                      var dataURL = canvas.toDataURL();
                      document.getElementById("canvasimg").src = dataURL;
                      document.getElementById("canvasimg").style.display = "inline";
                  }
                  

                  它给了我错误:

                  未捕获的安全错误:无法在HTMLCanvasElement"上执行toDataURL":可能无法导出受污染的画布.

                  Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

                  我该怎么办?

                  推荐答案

                  出于安全原因,您的本地驱动器被声明为其他域";并且会污染画布.

                  For security reasons, your local drive is declared to be "other-domain" and will taint the canvas.

                  (那是因为您最敏感的信息可能在您的本地驱动器上!).

                  (That's because your most sensitive info is likely on your local drive!).

                  在测试时尝试以下解决方法:

                  While testing try these workarounds:

                  • 将所有与页面相关的文件(.html、.jpg、.js、.css 等)放在桌面上(而不是放在子文件夹中).

                  • Put all page related files (.html, .jpg, .js, .css, etc) on your desktop (not in sub-folders).

                  将您的图片发布到支持跨域共享的网站(如 dropbox.com 或 GitHub).确保将图像放在 Dropbox 的公用文件夹中,并在下载图像时设置交叉源标志 (var img=new Image(); img.crossOrigin="anonymous" ...)

                  Post your images to a site that supports cross-domain sharing (like dropbox.com or GitHub). Be sure you put your images in dropbox's public folder and also set the cross origin flag when downloading the image (var img=new Image(); img.crossOrigin="anonymous" ...)

                  在您的开发计算机上安装网络服务器(IIS 和 PHP 网络服务器都有免费版本,可以很好地在本地计算机上运行).

                  Install a webserver on your development computer (IIS and PHP web servers both have free editions that work nicely on a local computer).

                  这篇关于受污染的画布不得出口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何清除画布以进行重绘 下一篇:Html5画布drawImage:如何应用抗锯齿

                  相关文章

                • <small id='4hLvO'></small><noframes id='4hLvO'>

                • <legend id='4hLvO'><style id='4hLvO'><dir id='4hLvO'><q id='4hLvO'></q></dir></style></legend>
                  1. <i id='4hLvO'><tr id='4hLvO'><dt id='4hLvO'><q id='4hLvO'><span id='4hLvO'><b id='4hLvO'><form id='4hLvO'><ins id='4hLvO'></ins><ul id='4hLvO'></ul><sub id='4hLvO'></sub></form><legend id='4hLvO'></legend><bdo id='4hLvO'><pre id='4hLvO'><center id='4hLvO'></center></pre></bdo></b><th id='4hLvO'></th></span></q></dt></tr></i><div id='4hLvO'><tfoot id='4hLvO'></tfoot><dl id='4hLvO'><fieldset id='4hLvO'></fieldset></dl></div>

                        <bdo id='4hLvO'></bdo><ul id='4hLvO'></ul>

                    1. <tfoot id='4hLvO'></tfoot>