久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='2aHXo'></tfoot>

    • <bdo id='2aHXo'></bdo><ul id='2aHXo'></ul>
    1. <legend id='2aHXo'><style id='2aHXo'><dir id='2aHXo'><q id='2aHXo'></q></dir></style></legend>

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

      <i id='2aHXo'><tr id='2aHXo'><dt id='2aHXo'><q id='2aHXo'><span id='2aHXo'><b id='2aHXo'><form id='2aHXo'><ins id='2aHXo'></ins><ul id='2aHXo'></ul><sub id='2aHXo'></sub></form><legend id='2aHXo'></legend><bdo id='2aHXo'><pre id='2aHXo'><center id='2aHXo'></center></pre></bdo></b><th id='2aHXo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2aHXo'><tfoot id='2aHXo'></tfoot><dl id='2aHXo'><fieldset id='2aHXo'></fieldset></dl></div>

        img 標簽的 HTML 跨域屬性

        HTML crossorigin attribute for img tag(img 標簽的 HTML 跨域屬性)
        <legend id='8Y4kz'><style id='8Y4kz'><dir id='8Y4kz'><q id='8Y4kz'></q></dir></style></legend>
          <tbody id='8Y4kz'></tbody>

          <small id='8Y4kz'></small><noframes id='8Y4kz'>

          • <bdo id='8Y4kz'></bdo><ul id='8Y4kz'></ul>

              1. <i id='8Y4kz'><tr id='8Y4kz'><dt id='8Y4kz'><q id='8Y4kz'><span id='8Y4kz'><b id='8Y4kz'><form id='8Y4kz'><ins id='8Y4kz'></ins><ul id='8Y4kz'></ul><sub id='8Y4kz'></sub></form><legend id='8Y4kz'></legend><bdo id='8Y4kz'><pre id='8Y4kz'><center id='8Y4kz'></center></pre></bdo></b><th id='8Y4kz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8Y4kz'><tfoot id='8Y4kz'></tfoot><dl id='8Y4kz'><fieldset id='8Y4kz'></fieldset></dl></div>

                1. <tfoot id='8Y4kz'></tfoot>
                2. 本文介紹了img 標簽的 HTML 跨域屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試了解如何為 img 標簽使用 crossorigin 屬性.我找不到一個很好的例子(我發現的關于啟用 CORS 的圖像是用 JavaScript 代碼解釋的,因此我看不到帶有 img 標簽的 crossorigin 屬性.

                  I am trying to understand how to use the crossorigin attribute for the img tag. I couldn't find a good example (The ones I found about CORS enabled images are explained with JavaScript codes, therefore I couldn't see the crossorigin attribute with the img tag.

                  我有一個猜測,如果我理解錯誤,請糾正我的錯誤.

                  I have got a guess, please correct my mistakes if I understood something wrong.

                  首先可以編寫下面的代碼來將圖像繪制到畫布上:

                  First of all one can write the code piece below to draw an image to canvas:

                  <canvas id="canvas" width=400 height=400></canvas>
                  <br><br>
                  <img id="image" src="http://...." alt="" width="400" height="400">
                  <script>
                  function draw() {
                      var canvas = document.getElementById("canvas");
                      var context = canvas.getContext("2d");
                      var img = new Image();
                      img.crossOrigin = "Anonymous";
                      img.src = document.getElementById("image").value;
                      context.drawImage(img, 40, 40);
                  }
                  </script>
                  

                  下面的代碼是否等同于上面的代碼?它不包含img.crossOrigin",但在 img 標簽中有 crossorigin 屬性.

                  Is the code below equivalent to the upper one? It doesn't include "img.crossOrigin" but have crossorigin attribute in the img tag.

                  <canvas id="canvas" width=400 height=400></canvas>
                  <br><br>
                  <img id="image" crossorigin="anonymous"src="http://...." alt="" width="400" height="400">
                  <script>
                  function draw() {
                      var canvas = document.getElementById("canvas");
                      var context = canvas.getContext("2d");
                      var img = new Image();
                      img.src = document.getElementById("image").value;
                      context.drawImage(img, 40, 40);
                  }
                  </script>
                  

                  說實話,我無法進行實驗,因為我不知道哪個網站允許將其圖像用作 CORS.

                  To tell the truth I cannot make experiments because I don't know what site allows to use its images as CORS.

                  我的猜測是,如果 CORS 請求是由匿名完成的,如果站點允許在畫布中使用其圖像,您可以在畫布中繪制它,如果不是,即使請求是匿名完成的,您也無法在畫布中繪制它(我不確定我是否在這里).因此,上述兩個示例都必須匿名請求 CORS.

                  What I guess is that, if a site allow to use its images in canvas if the CORS request is done by anonymously you can draw it in canvas, if not you cannot draw it in canvas even if the request is done by anonymously (I am not sure if I am right here). Therefore both of the examples above must be requesting CORS anonymously.

                  你能說如果他們兩個工作相同嗎?如果不是,您能否解釋一下原因并給我一個使用帶有 img 標簽的 crossorigin 屬性的示例?

                  Could you please say if both of them works the same? If not, could you please explain why and give me an example using the crossorigin attribute with the img tag?

                  推薦答案

                  由于您使用#image 元素作為圖像的來源,因此您的代碼的兩個版本大致相同.

                  Since you are using the #image element as the source for your image, the 2 versions of your code are roughly equivalent.

                  但是...

                  img 元素中沒有 crossorigin="anonymous" 的版本可能仍然會產生跨域違規.

                  The version without crossorigin="anonymous" in the img element will probably still generate a cross-domain violation.

                  這是因為圖像最初加載到 img 元素中沒有將跨域標志設置為匿名.

                  That's because the image is originally loaded into the img element without the cross-origin flag set to anonymous.

                  javascript 代碼可能會使用來自 img 元素的圖像的緩存版本,而不是嘗試從 http://...

                  The javascript code will likely use the cached version of the image from the img element rather than trying to reload it from http://...

                  這意味著緩存的圖像數據仍會將畫布污染為包含跨域內容.

                  This means the cached image data will still taint the canvas as containing cross-origin content.

                  順便說一句,您的代碼中有語法錯誤:

                  BTW, a syntax error in your code:

                  // Not:  img.src = document.getElementById("image").value;
                  
                  img.src = document.getElementById("image").src;
                  

                  這篇關于img 標簽的 HTML 跨域屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  document.write() overwriting the document?(document.write() 覆蓋文檔?)
                  AngularJS Error: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https(AngularJS 錯誤:跨源請求僅支持協議方案:http、data、chrome-extension、https) - IT屋-程序員軟件開發技術分
                  POSTing to external API throws CORS but it works from Postman(發布到外部 API 會引發 CORS,但它適用于 Postman)
                  Benefit of CORS over cross-domain messaging(CORS 對跨域消息傳遞的好處)
                  Ajax CORS Request with http 401 in preflight(預檢中帶有 http 401 的 Ajax CORS 請求)
                  <legend id='0Hkzp'><style id='0Hkzp'><dir id='0Hkzp'><q id='0Hkzp'></q></dir></style></legend>

                      <tbody id='0Hkzp'></tbody>

                      <i id='0Hkzp'><tr id='0Hkzp'><dt id='0Hkzp'><q id='0Hkzp'><span id='0Hkzp'><b id='0Hkzp'><form id='0Hkzp'><ins id='0Hkzp'></ins><ul id='0Hkzp'></ul><sub id='0Hkzp'></sub></form><legend id='0Hkzp'></legend><bdo id='0Hkzp'><pre id='0Hkzp'><center id='0Hkzp'></center></pre></bdo></b><th id='0Hkzp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0Hkzp'><tfoot id='0Hkzp'></tfoot><dl id='0Hkzp'><fieldset id='0Hkzp'></fieldset></dl></div>
                    • <small id='0Hkzp'></small><noframes id='0Hkzp'>

                        <bdo id='0Hkzp'></bdo><ul id='0Hkzp'></ul>

                        <tfoot id='0Hkzp'></tfoot>

                            主站蜘蛛池模板: 91亚洲国产| 国产欧美一区二区三区日本久久久 | 欧美lesbianxxxxhd视频社区 | 美女艹b| 日日摸日日碰夜夜爽亚洲精品蜜乳 | jlzzjlzz国产精品久久 | 国产99久久久国产精品 | 成人一区av| 亚洲高清中文字幕 | 亚洲天堂中文字幕 | 午夜精品久久久久久久久久久久久 | 在线观看特色大片免费网站 | 精品国产欧美一区二区三区成人 | 中文字幕欧美日韩 | www久久久 | 二区在线观看 | 狠狠色综合久久婷婷 | 国产精品高潮呻吟久久aⅴ码 | 国产福利网站 | 91久久国产综合久久 | 国产成人精品999在线观看 | 91精品国产综合久久久久久漫画 | 日韩成人免费av | 国产成人免费 | 艹逼网| 亚洲精品永久免费 | 国产精品一区二区视频 | 欧美精品在线观看 | 国产乱精品一区二区三区 | 国产免费人成xvideos视频 | 国产精品日日摸夜夜添夜夜av | 久久久.com | 日韩成人免费 | 午夜天堂精品久久久久 | 精品网| 欧美一级黄色网 | 天天插天天操 | 国外成人在线视频 | 亚洲 欧美 激情 另类 校园 | 精品免费| 久久精品aaa|