Ian Campbell
Ian Campbell

Reputation: 2748

Is there a way to force HTML to open an mp3 in the OS?


Is there a cross-browser way of forcing something like:

<a href = "/mp3s/qwerty.mp3">Click to Listen or Download</a>

...to open in the operating system, and not in a browser plug-in (i.e. Quicktime)? I want the example link above to always show the OS dialog window: "Open With... Save As...".


Is this maybe possible with Javascript, or with the ActiveXObject for Windows OS at least?



Upvotes: 0

Views: 181

Answers (3)

Saurabh
Saurabh

Reputation: 1069

I have not used it. But perhaps this is what is best for you.

http://www.w3schools.com/html5/html5_audio.asp

Again haven't tried it. And this is HTML5. Let us know what you find out.

Upvotes: 1

Per Johansson
Per Johansson

Reputation: 6887

You can do this by adding the HTTP header

Content-Disposition: attachment

when qwerty.mp3 is requested. Can't tell you exactly how without knowing what HTTP server you are using.

Details in RFC2183

Upvotes: 3

Konerak
Konerak

Reputation: 39773

There is no 100% foolproof will-always-work way to do this, since the browser can always decide how to handle this in the end.

However, most sites that want to force a download, toy with the headers: send the mp3 file with Content-disposition: attachment or Content-type: application/octet-stream. This will suggest to the browser to offer to store the file as an attachment, and not show it internally.

Upvotes: 1

Related Questions