Highcharts:如何在window.location.href中指定文件名,将图像导出到本地磁盘

时间:2014-10-05 17:12:01

标签: javascript highcharts

This jsfiddle显示了如何将Highcharts图表导出到png文件,但是没有显示如何指定文件名。

这样的东西
var image = canvas.toDataURL("image/png")
            .replace("image/png", "image/octet-stream"); 

image.filename = "file.png";    <=== this doesn't work

// Save locally
window.location.href = image;

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

var image = Canvas.toDataURL(&#34; image / png&#34;)。replace(&#34; image / png&#34;,&#34; image / octet-stream&#34;);                 window.location.href =图像; //它会在本地保存