0

I have an audio file on my website. It's played once you click a button and it works and thats all well and good. However, I need it so that when you click the 3 dots at the end, users can download said audio. audio screenshot. Any ideas on how to achieve this without javascript?

I've looked up a couple solutions via web3schools and sololearn. I don't have the firmest grasp on HTML and CSS so I just tried copying what they had, but none of it seemed to work.

want download here after clicking 3 dots

<a href="Audio/Commercial.mp3" class="cta"< Commercial Demo</a< (ignore the reversed > symbol) this is the code I have for one buttons users would press to hear the audio. I just need to make it downloadable as well.

noobcoder
  • 1
  • 1
  • Does this answer your question? [How can I create download link in HTML?](https://stackoverflow.com/questions/2793751/how-can-i-create-download-link-in-html) – Aaron Stanek Jul 21 '23 at 23:59
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jul 22 '23 at 05:04

2 Answers2

0

You can do this without javascript by using the download attribute for the <a> tag.

<a href="FILE_PATH" download>Download audio file</a>

Optionally, you can suggest a file name for the downloaded file by adding...

<a href="FILE_PATH" download="YourFileName">Download audio file</a>

https://www.w3schools.com/tags/att_a_download.asp

jdosh
  • 11
  • 3
0

You can use the download attribute in a hyperlink. Here's an example:

<a href="example.com/path/to/audio.mp3" download="audio_name">
  Download sound
</a>

You can also make it more visually appealing by using a button inside the hyperlink. Here's another example:

<a href="example.com/path/to/audio.mp3" download="audio_name">
  <button class="download_button">
    Download sound
  </button>
</a>

If you don't need the class or if it's declared under a different name, feel free to change it! :)