简体   繁体   中英

Downloading a .wav or .mp3 with Javascript

I need to have a link on my website page download a sound file. I know that if you direct a link to say, a .doc file it will open a blank page and download the file (because the browser can't read the file), but that does not work with sound files- they are opened with a media player in the browser. How can I automatically download this file instead of opening it in-browser?

This is in Chrome, if that makes a difference.

<a href='file.mp3' download='Very-Very-Good.mp3'>download</a>
<a href="javascript:window.open('song.mp3')">DownLoad Song</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM