【问题标题】:Saving canvas to png: Is it possible to remove MIME type warning message in Chrome?将画布保存为 png:是否可以在 Chrome 中删除 MIME 类型的警告消息?
【发布时间】:2019-06-03 17:07:04
【问题描述】:

我正在尝试将画布另存为图像。

一切正常,但我在浏览器中收到一条警告消息: “资源被解释为文档,但使用 MIME 类型的图像/八位字节流传输......”

我使用以下代码:

let img = canvas
  .toDataURL("image/png")
  .replace("image/png", "image/octet-stream");
window.location.href = img;

是否可以让浏览器不给出这个警告?

【问题讨论】:

    标签: javascript google-chrome mime-types


    【解决方案1】:

    Chrome 无法识别 image/octet-stream。任意二进制数据的 MIME 类型为application/octet-stream

    但是你没有任意的二进制数据,你在数据 URL 中有一个 PNG。 There are more user-friendly ways to download that.

    【讨论】:

      猜你喜欢
      • 2011-03-15
      • 2012-06-04
      • 1970-01-01
      • 2015-06-28
      • 2012-07-30
      • 1970-01-01
      • 2010-12-31
      • 2012-06-27
      • 2014-02-20
      相关资源
      最近更新 更多