[英]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.
我知道如果你直接链接一个 .doc 文件,它会打开一个空白页面并下载文件(因为浏览器无法读取文件),但这不适用于声音文件——它们是用浏览器中的媒体播放器。 How can I automatically download this file instead of opening it in-browser?
如何自动下载此文件而不是在浏览器中打开它?
This is in Chrome, if that makes a difference.这是在 Chrome 中,如果这有区别的话。
<a href='file.mp3' download='Very-Very-Good.mp3'>download</a>
<a href="javascript:window.open('song.mp3')">DownLoad Song</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.