简体   繁体   English

点击下载MP3而不是打开标签

[英]Download MP3 on click instead of opening tab

Currently the button below, opens the MP3 into a new tab I am interested in having it pop up a direct download portion on click. 目前下面的按钮,将MP3打开到一个新选项卡,我有兴趣让它在点击时弹出直接下载部分。

Example

<a href="https://skyvault.co/show/audio?filename=5qpxt5E11oyHEG">Testing</a>

JSFiddle . JSFiddle

You can use the download attribute. 您可以使用下载属性。

<a href="https://skyvault.co/show/audio?filename=5qpxt5E11oyHEG" download>Testing</a>

If you want to change the file name, as it says in the documentation of W3Schools : 如果要更改文件名,如W3Schools文档中所述:

Specify a value for the download attribute, which will be the new filename of the downloaded file ("w3logo.jpg" instead of "myw3schoolsimage.jpg"): 指定下载属性的值,该属性将是下载文件的新文件名(“w3logo.jpg”而不是“myw3schoolsimage.jpg”):

您可以使用download属性,也可以命名下载的文件(在这种情况下,可能是mp3文件的名称):

<a href="https://skyvault.co/show/audiofilename=5qpxt5E11oyHEG" download='name_of_file.mp3'>Testing</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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