How to name a downloadable file in JavaScript using data url

Question:

All in all I did like this

window.open("data:application/octet-stream," + (JSON.stringify(content)), "fail");

Now the question arose how to name the file.

Answer:

<a download='FileName' href='your_url'> , but not for all browsers ( http://caniuse.com/#feat=download ). your_url can be a Data URI like yours.

To automatically download this case, I think you just need to create an invisible link and make jQuery.click () on it.

Scroll to Top