I am facing a challenge in creating a download button that should, upon clicking, locate the URL of the current playing song and initiate the download process. However, pressing the button currently opens the file location instead of downloading it. I am aware that server-side settings can be adjusted to enable attachment downloads, but unfortunately, I do not have access to the server in this particular scenario.
var downloadButton = $("button");
var songURL = "shorturl.at/cfikM";
downloadButton.on("click", function(){
top.location.href = songURL;
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button>Download</button>
<a href="URL" download> Download </a>
Any suggestions on how to achieve this?