pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <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="xr9vf1f" 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="7dzj9hd" 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="p5r7z7b" 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>

                            主站蜘蛛池模板: 无锡市珂妮日用化妆品有限公司|珂妮日化官网|洗手液厂家 | 热熔胶网膜|pes热熔网膜价格|eva热熔胶膜|热熔胶膜|tpu热熔胶膜厂家-苏州惠洋胶粘制品有限公司 | 电杆荷载挠度测试仪-电杆荷载位移-管桩测试仪-北京绿野创能机电设备有限公司 | 骁龙云呼电销防封号系统-axb电销平台-外呼稳定『免费试用』 | 氢氧化钙设备_厂家-淄博工贸有限公司 | 厌氧反应器,IC厌氧反应器,厌氧三相分离器-山东创博环保科技有限公司 | 厂房出售_厂房仓库出租_写字楼招租_土地出售-中苣招商网-中苣招商网 | 临沂招聘网_人才市场_招聘信息_求职招聘找工作请认准【马头商标】 | 颚式破碎机,圆锥破碎机,制砂机-新乡市德诚机电制造有限公司 | 耐火砖厂家,异形耐火砖-山东瑞耐耐火材料厂 | ptc_浴霸_大巴_干衣机_呼吸机_毛巾架_电动车加热器-上海帕克 | 防勒索软件_数据防泄密_Trellix(原McAfee)核心代理商_Trellix(原Fireeye)售后-广州文智信息科技有限公司 | 广东泵阀展|阀门展-广东国际泵管阀展览会 | 短信营销平台_短信群发平台_106短信发送平台-河南路尚 | 济宁工业提升门|济宁电动防火门|济宁快速堆积门-济宁市统一电动门有限公司 | 重庆磨床过滤机,重庆纸带过滤机,机床伸缩钣金,重庆机床钣金护罩-重庆达鸿兴精密机械制造有限公司 | 别墅图纸超市|别墅设计图纸|农村房屋设计图|农村自建房|别墅设计图纸及效果图大全 | 找培训机构_找学习课程_励普教育 | 高扬程排污泵_隔膜泵_磁力泵_节能自吸离心水泵厂家-【上海博洋】 | 立式_复合式_壁挂式智能化电伴热洗眼器-上海达傲洗眼器生产厂家 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 真空泵厂家_真空泵机组_水环泵_旋片泵_罗茨泵_耐腐蚀防爆_中德制泵 | 广东风淋室_广东风淋室厂家_广东风淋室价格_广州开源_传递窗_FFU-广州开源净化科技有限公司 | 减速机三参数组合探头|TSM803|壁挂式氧化锆分析仪探头-安徽鹏宸电气有限公司 | 无痕胶_可移胶_无痕双面胶带_可移无痕胶厂家-东莞凯峰 | 冷却塔厂家_冷却塔维修_冷却塔改造_凉水塔配件填料公司- 广东康明节能空调有限公司 | 山东限矩型液力偶合器_液力耦合器易熔塞厂家-淄博市汇川源机械厂 | 【官网】博莱特空压机,永磁变频空压机,螺杆空压机-欧能优 | 塑胶跑道_学校塑胶跑道_塑胶球场_运动场材料厂家_中国塑胶跑道十大生产厂家_混合型塑胶跑道_透气型塑胶跑道-广东绿晨体育设施有限公司 | 无缝钢管-聊城无缝钢管-小口径无缝钢管-大口径无缝钢管 - 聊城宽达钢管有限公司 | 天津拓展_天津团建_天津趣味运动会_天津活动策划公司-天津华天拓展培训中心 | 磁力抛光机_磁力研磨机_磁力去毛刺机-冠古设备厂家|维修|租赁【官网】 | 斗式提升机_链式斗提机_带式斗提机厂家无锡市鸿诚输送机械有限公司 | 变位机,焊接变位机,焊接变位器,小型变位机,小型焊接变位机-济南上弘机电设备有限公司 | 耐高温风管_耐高温软管_食品级软管_吸尘管_钢丝软管_卫生级软管_塑料波纹管-东莞市鑫翔宇软管有限公司 | 扬尘在线监测系统_工地噪声扬尘检测仪_扬尘监测系统_贝塔射线扬尘监测设备「风途物联网科技」 | 恒温水槽与水浴锅-上海熙浩实业有限公司 | 冰晶石|碱性嫩黄闪蒸干燥机-有机垃圾烘干设备-草酸钙盘式干燥机-常州市宝康干燥 | 电机铸铝配件_汽车压铸铝合金件_发动机压铸件_青岛颖圣赫机械有限公司 | 驾驶人在线_专业学车门户网站 | 丝杆升降机-不锈钢丝杆升降机-非标定制丝杆升降机厂家-山东鑫光减速机有限公司 | 购买舔盐、舔砖、矿物质盐压块机,鱼饵、鱼饲料压块机--请到杜甫机械 |