[whatwg] "Content-Disposition" property for <a> tags

Glenn Maynard glenn at zewt.org
Sat Apr 30 11:05:05 PDT 2011

On Mon, Apr 11, 2011 at 1:28 PM, Glenn Maynard <glenn at zewt.org> wrote:
> On Mon, Apr 11, 2011 at 12:48 PM, Eric Uhrhane <ericu at google.com> wrote:
>> Folks did propose making FileSaver do this at TPAC, but we haven't
>> gotten around to hashing out the details yet.  The idea was that
>> FileSaver would take a URL instead of a Blob, and thus could also be
>> used for downloading arbitrary links.
> I missed that API; I like that approach.  <a href=url
> onclick="if("FileSaver" in window) { new FileSaver(this.href); return false;
> }">

Thinking about this some more, FileSaver can't handle
"Content-Disposition: filename" adequately.  For example, compare
FileSaver to the approach originally posted (with a slight

<a href="http://example.com/datastore/76cf656d2240be006aef7466a45628d1e531eb5c"
onclick="new FileSaver(this.href, 'downloaded_image.psd'); return
false;">Download PSD</a>

<a href="http://example.com/datastore/76cf656d2240be006aef7466a45628d1e531eb5c"
disposition=attachment filename=downloaded_image.psd>Download PSD</a>

The FileSaver method breaks if the user opens the context menu and
selects "save link as".  It also breaks if he selects the region of
text and uses a download manager's "download all selected links"
feature.  Tools like wget couldn't support this.  Drag-and-drop could
also take hints from @filename, so dragging the link into Photoshop
could give it the correct filename.

Glenn Maynard

More information about the whatwg mailing list