Reputation: 23475
I have a url to a .mp3 file and its forcing me to download it when loading it on the client side. Is there a way to disable this forced download and store this mp3 file into a variable so I can load it into my javascript mp3 player?
Upvotes: 0
Views: 374
Reputation: 5250
You could do something like this:
<a id="link" href="http://example.com/path/some.mp3">link</a>
<script>
$("#link").on('click', function (e) {
e.preventDefault();
var url = $("#link").attr("href");
var a = new Audio(url);
a.play();
});
</script>
Upvotes: 1