download audio file javascript

Solutions on MaxInterview for download audio file javascript by the best coders in the world

showing results for - "download audio file javascript"
Giada
10 Jan 2021
1var filename = url.substring(url.lastIndexOf("/") + 1).split("?")[0];
2  var xhr = new XMLHttpRequest();
3  xhr.responseType = 'blob';
4  xhr.onload = function() {
5    var a = document.createElement('a');
6    a.href = window.URL.createObjectURL(xhr.response);
7    a.download = filename; 
8    a.style.display = 'none';
9    document.body.appendChild(a);
10    a.click();
11    delete a;
12  };
13  xhr.open('GET', url);
14  xhr.send();