I am having an anchor link on the page which points to an MP3 file. I want to be able to download this file with Right-click + Save Target As..
and also by single clicking on the link.
Currently, I am facing a problem where different browsers have different behavior. IE plays the file in WMP, Firefox prompts the download box and Chrome starts playing file inline. Expected behavior on single click is that browser should either download the file or give me a download dialog.
I have tried following:
- Creating a hidden
iframe
on the page and giving it is as target for my anchor link, also tried creating a form with my desired MP3 file location as its action inside thisiframe
and submitting the form on anchor link click event - Setting
window.location = MP3 URL
on link click - Tried multiple combinations of
window.open
None of these has been able to help me. I just can't get the download dialog on link-click.
The innocent anchor link looks like:
<a id="someID" href="myMP3file" target="whatever" title="Download" class="someClass">Download Me!</a>