skip to Main Content

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.

2

Answers


  1. 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

    Login or Signup to reply.
  2. 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! 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search