Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #21758 > unrolled thread

FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? (2013-10-28)

Started by"FAQ server" <javascript@dotinternet.be>
First post2013-10-28 00:00 +0000
Last post2013-10-28 08:31 -0700
Articles 4 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? (2013-10-28) "FAQ server" <javascript@dotinternet.be> - 2013-10-28 00:00 +0000
    Re: FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? (2013-10-28) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-10-27 18:30 -0700
      Re: FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? (2013-10-28) Stefan Weiss <krewecherl@gmail.com> - 2013-10-28 10:25 +0100
        Re: FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? (2013-10-28) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-10-28 08:31 -0700

#21758 — FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? (2013-10-28)

From"FAQ server" <javascript@dotinternet.be>
Date2013-10-28 00:00 +0000
SubjectFAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? (2013-10-28)
Message-ID<526da99c$0$305$14726298@news.sunsite.dk>
-----------------------------------------------------------------------
FAQ Topic - How do I prompt a "Save As" dialog for an
accepted mime type?
-----------------------------------------------------------------------

It is not possible with client-side javascript.

Some browsers accept the Content-Disposition header, but this
must be added by the server. Taking the form:-
`Content-Disposition: attachment; filename=filename.ext`

<URL: http://classicasp.aspfaq.com/general/how-do-i-prompt-a-save-as-dialog-for-an-accepted-mime-type.html>
<URL: http://support.microsoft.com/kb/q260519/>


The complete comp.lang.javascript FAQ is at
http://jibbering.com/faq/

-- 

The sendings of these daily posts are proficiently hosted
by http://www.pair.com.

[toc] | [next] | [standalone]


#21759

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2013-10-27 18:30 -0700
Message-ID<7b34fd03-47f0-4f4b-87b4-e8c3e84eed23@googlegroups.com>
In reply to#21758
On Sunday, October 27, 2013 7:00:00 PM UTC-5, FAQ server wrote:
> -----------------------------------------------------------------------
> FAQ Topic - How do I prompt a "Save As" dialog for an
> accepted mime type?
> -----------------------------------------------------------------------
> 
> It is not possible with client-side javascript. 
> Some browsers accept the Content-Disposition header, but this
> must be added by the server. Taking the form:-
> `Content-Disposition: attachment; filename=filename.ext`
> 
> <URL: http://classicasp.aspfaq.com/general/how-do-i-prompt-a-save-as-dialog-for-an-accepted-mime-type.html>
> 
> <URL: http://support.microsoft.com/kb/q260519/>
> 
> The complete comp.lang.javascript FAQ is at
> 
> http://jibbering.com/faq/

In modern browsers the <a/> tag has a "download" attribute that can be used for this purpose:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download

Just set the appropriate datatype, then trigger the "click" event.

In legacy IE, one can utilize execCommand with the "SaveAs" option for a limited subset of mimetypes.

[toc] | [prev] | [next] | [standalone]


#21760

FromStefan Weiss <krewecherl@gmail.com>
Date2013-10-28 10:25 +0100
Message-ID<l4laic$8sp$1@news.albasani.net>
In reply to#21759
On 2013-10-28 02:30, Michael Haufe (TNO) wrote:
> In modern browsers the <a/> tag has a "download" attribute that can
> be used for this purpose:
> 
> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download

Some modern browsers. There's currently no support for the download
attribute in any version of IE, Safari, the Android browser, or Opera
Mini. According to <http://beta.caniuse.com/#feat=download>, the
worldwide support rate is less than 50% at this time.

- stefan

[toc] | [prev] | [next] | [standalone]


#21761

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2013-10-28 08:31 -0700
Message-ID<6789d853-4de0-468b-88a4-319956ba7b7d@googlegroups.com>
In reply to#21760
On Monday, October 28, 2013 4:25:31 AM UTC-5, Stefan Weiss wrote:
> Some modern browsers. There's currently no support for the download
> attribute in any version of IE, Safari, the Android browser, or Opera
> Mini. According to <http://beta.caniuse.com/#feat=download>, the
> worldwide support rate is less than 50% at this time.

I overlooked the File API in my last post as well. There is also support for:

window.msSaveBlob(blob, filename)

Some (questionable) examples for other browsers:
<http://hackworthy.blogspot.com/2012/05/savedownload-data-generated-in.html>

Still, this bumps up the state of affairs slightly from traditionally impossible to painful.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web