jami1955
jami1955

Reputation: 1

Prompt browser download dialogue box

Normal: <a href="/soundfile.mp3">download</a>

The reason I can't do this is it's on a Wordpress installation with a plugin (wpaudio) which turns every mp3 filein the code into a mini player which when clicked streams the file. So that link above would appear as a link, with a play button beside it, when clicked would stream the file, and not prompt the download dialogue box. With 99% of the mp3 files on this site that's exactly what is needed.

However for one file, I need to enable the user to click the linked word download, and get the save or open dialogue box, along with subsequent progress bar (if enabled in his browser preferences). PHP or Javascript is fine, either will do, anybody know how to get that working?

Upvotes: 0

Views: 569

Answers (1)

gilly3
gilly3

Reputation: 91467

According to the plugin site you linked to:

Convert all mp3 links
To turn every mp3 link on your blog into a player, select Convert all mp3 links in the WPaudio settings.

Convert some mp3 links
For any mp3 link you'd like to convert to a player, add the wpaudio class like this:
<a href="http://url"class="wpaudio">Artist - Song</a>

So, you probably just don't want to have to go give every link that class right? So, use JavaScript to do it. Give the links you don't want converted a class of no-wpaudio or something, and use JavaScript to add the class to all the links without the no-wpaudio class. Hopefully you are using jQuery:

$("a[href$='.mp3']:not(.no-wpaudio)").addClass("wpaudio");

If not, what a pain, but it can be done. Let me know if you want the non-jQuery code.

Upvotes: 2

Related Questions