Stephen wrote:
Michael Winter wrote: On Sat, 24 Jan 2004 09:40:14 -0500, Robert Oschler
<no_replies@fake_email_address.invalid> wrote:
[...] left-clicking the link to the audio file initiates
client-
side streaming/playing of the audio file. Is there a way with
Javascript to make a left-click trigger a download of the file instead?
No[1].
If you can use a server-side script, you can send the file with the
application/octet-stream content type, which will force the "Save as"
dialog. [...]
And, AIUI, even this might not work in some browsers because those
browsers ignore the Content-type header and use the file's extension to
determine how to treat it. And it appears some browsers can be
configured to use either content-type or file extension.
Stephen
Adding the following headers from the server (as an example) seems to work
reliably in all browsers I've tested:
Content-Disposition: attachment; filename="file.xls"
Content-type: application/vnd.ms-excel
Even IE on a Windows system with Excel installed prompts to download the file,
rather then loading it in-place in IE.
Adding the following headers from the server ensures most browser will force a
download of it:
Content-Disposition: attachment; filename="file.mp3"
Content-type: application/octet-stream
--
| Grant Wagner <gw*****@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html