Suggest file name for data: URI

I am generating an SVG string in JavaScript.

I serve it for the user:

window.open("data:image/svg+xml," + svg_xml_string); 

When you try to save this page in Chrome, it will offer to save, since download.svg is in any case, can I change the default file name for downloading?


I tried:

 data:image/svg+xml;headers=Content-Disposition%3Aattachment%3Bfilename%3D%22suggest.svg%22,... 

But that will not work.

+6
source share
1 answer

This is solved in some, very new browsers. The comment question also mentions the proposed extension for Opera that you came up with, but I think it's best to use the <a download="..."> attribute and suggest that users with older browsers set the file name for themselves while loading.

-1
source

All Articles