Answers for "download audio file javascript"

1

download audio file javascript

var filename = url.substring(url.lastIndexOf("/") + 1).split("?")[0];
  var xhr = new XMLHttpRequest();
  xhr.responseType = 'blob';
  xhr.onload = function() {
    var a = document.createElement('a');
    a.href = window.URL.createObjectURL(xhr.response);
    a.download = filename; 
    a.style.display = 'none';
    document.body.appendChild(a);
    a.click();
    delete a;
  };
  xhr.open('GET', url);
  xhr.send();
Posted by: Guest on December-28-2020

Code answers related to "download audio file javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language