在数据URL中,资源被解释为文档但使用MIME类型application / pdf进行传输

时间:2016-09-21 01:28:41

标签: google-chrome pdf mime

当我有:

<iframe src="data:application/pdf;base64,JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwogIC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAvTWVkaWFCb3ggWyAwIDAgMjAwIDIwMCBdCiAgL0NvdW50IDEKICAvS2lkcyBbIDMgMCBSIF0KPj4KZW5kb2JqCgozIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2UKICAvUGFyZW50IDIgMCBSCiAgL1Jlc291cmNlcyA8PAogICAgL0ZvbnQgPDwKICAgICAgL0YxIDQgMCBSIAogICAgPj4KICA+PgogIC9Db250ZW50cyA1IDAgUgo+PgplbmRvYmoKCjQgMCBvYmoKPDwKICAvVHlwZSAvRm9udAogIC9TdWJ0eXBlIC9UeXBlMQogIC9CYXNlRm9udCAvVGltZXMtUm9tYW4KPj4KZW5kb2JqCgo1IDAgb2JqICAlIHBhZ2UgY29udGVudAo8PAogIC9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCjcwIDUwIFRECi9GMSAxMiBUZgooSGVsbG8sIHdvcmxkISkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDEwIDAwMDAwIG4gCjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAwMDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9vdCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G">
</iframe> 

由JS注入,甚至在本地静态HTML文件中注入, Chrome说Resource interpreted as Document but transferred with MIME type application/pdf并将整个内容转储到调试控制台。

如何消除此警告?

1 个答案:

答案 0 :(得分:6)

您应该使用HTML Object代替:

    <table class="table table-striped">
      <thead>
        <tr>
          <th>#</th>
          <th>Product Name</th>
          <th>Product Price</th>
          <th>Product Quantity</th>
          <th>Category</th>
          <th>Action</th>
        </tr>
      </thead>
      <tbody>
    @foreach( $products as $product )
        <tr>
          <th>{{ $product->id }}</th>
          <td>{{ $product->productName }}</td>
          <td>{{ $product->productPrice }}</td>
          <td>{{ $product->quantity }}</td>
          <td>{{ $product->category_id }}</td>
          <td><button class='btn btn-success'>Edit</button> <button class='btn btn-danger'>Delete</button></td>
        </tr>
    @endforeach
      </tbody>
    </table> 

Plunker