【问题标题】:how to resolve Cross-Origin Read Blocking (CORB) blocked cross-origin response <URL>如何解决跨域读取阻塞 (CORB) 阻止的跨域响应 <URL>
【发布时间】:2019-03-12 13:40:11
【问题描述】:

我正在从我的 firebase 数据库中检索图像 URL,然后使用 URL 在我的页面中显示图像

问题是我收到了这个错误(PS 我使用的是来自维基百科的图片 URL)

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://fr.wikipedia.org/wiki/Capital_(magazine) with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
Cross-Origin Read Blocking (CORB) blocked cross-origin response <URL> with MIME type text/html. See <URL> for more details.

这是我的代码:

 var databaseRef = firebase.database().ref('titres/');
        databaseRef.once('value' , function(snapshot) {
        snapshot.forEach(function(childSnapshot) {
        var childKey = childSnapshot.key;
        var childData = childSnapshot.val();
        const list = document.getElementById('favoris');
        [childSnapshot].forEach(item => {
          // add title as an option in the select tag 
            var table = document.getElementById("myTable");
              var row = table.insertRow(0);
              var cell1 = row.insertCell(0);
              var cell2 = row.insertCell(1);
               let img = document.createElement('IMG');
               cell2.innerHTML=item.val().nom;
               if (item.val().URL_logo != undefined && item.val().URL_logo !="" && item.val()!=undefined &&  item.val().URL_logo !=" " )
               {  console.log(item.val().nom)  
                  console.log(item.val().URL_logo)

                    img.src=item.val().URL_logo ;
                    img.height="42"
                    img.width="100"
                    cell1.appendChild(img)

               }
               else{ cell1.innerHTML=item.val().nom;}

任何想法如何解决这个问题?

【问题讨论】:

标签: javascript cross-origin-read-blocking


【解决方案1】:

当您为图像设置src 时,您需要使用指向实际图像的 URL。

您似乎正在使用指向 Wikipedia HTML 文档的 URL。

【讨论】:

  • 或者维基百科本身可能会以某种错误来响应图像窃取。
  • @Pointy — 屏幕截图中的 URL 提示其他情况。
  • 好吧,其中一些看起来至少可能是图像 URL,但其他的则不是。 edit 哦,等等,这只是 wiki 的做事方式。
  • @Pointy — 以File:Some_Name.jpg 结尾的维基百科 URL 是关于托管在维基百科上的图像文件的 HTML 文档。
猜你喜欢
  • 2019-08-05
  • 2020-04-25
  • 1970-01-01
  • 1970-01-01
  • 2019-01-22
  • 1970-01-01
  • 2019-08-02
  • 2018-11-25
  • 2021-05-22
相关资源
最近更新 更多