If for example you follow the link:
data:application/octet-stream;base64,SGVsbG8=
The browser will prompt you to download a file consisting of the data held as base64 in the hyperlink itself. Is there any way of suggesting a default name in the markup? If not, is there a JavaScript solution?
Look at this link: http://lists.w3.org/Archives/Public/uri/2010Feb/0069.html
Quote:
Also there is some info in the rest messages of the discussion.
You actually can achieve this, in Chrome and FireFox.
Try the following url, it will download the code that was used.
I've looked a bit in firefox sources in netwerk/protocol/data/nsDataHandler.cpp
data handler only parses content/type and charset, and looks if there is ";base64" in the string
the rfc specifices no filename and at least firefox handles no filename for it, the code generates a random name plus ".part"
I've also checked firefox log
interesting files if you want to look at mozilla sources:
I think you can stop searching a solution for now, because I suspect there is none :)
as noticed in this thread html5 has
download
attribute, it works also on firefox 20 http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#attr-hyperlink-downloadThis one works with Firefox 43.0 (older not tested):
dl.js:
dl.html
If button is clicked it offered a file named hello.bin for download. Trick is to use File instead of Blob.
reference: https://developer.mozilla.org/de/docs/Web/API/File
There is a tiny workaround script on Google Code that worked for me:
http://code.google.com/p/download-data-uri/
It adds a form with the data in it, submits it and then removes the form again. Hacky, but it did the job for me. Requires jQuery.
This thread showed up in Google before the Google Code page and I thought it might be helpful to have the link in here, too.
According to RFC 2397, no, there isn't.
Nor does there appear to be any attribute of the<a>
element that you can use either.However HTML5 has subsequently introduced the
download
attribute on the<a>
element, although at the time of writing support is not universal (no MSIE support, for example)