【发布时间】:2016-08-27 10:57:15
【问题描述】:
当我尝试将我的画布下载为 PNG 图像时,浏览器会在新页面中打开该图像,但不要下载它... 我的下载代码:
$("#btnScaricaEtichetta").click(function(){
console.log("Download... ");
location.href = document.getElementById("latoSinistro").toDataURL();
this.download = "filename";
});
有没有办法简单地下载它? 抱歉英语不好,我是意大利人
【问题讨论】:
-
canvas.toDataURL("image/png")?你确定location.href正确地抓住了画布吗?另请查看image/png参数。 -
我已将“image/png”添加到 toDataURL 函数,但结果没有改变......浏览器打开一个窗口并显示带有此 url 的 img:data:image/png;base64 ,iVBORw0KGgoA ecc ecc (这么久)
-
在
this.download = "filename";行中,不清楚this指向什么。 -
@Kaiido ...只是想法...这些只是想法。 :-P
标签: javascript html canvas download png