Reputation: 4161
I'm using HTML5 audio tags. I have set source to some file. and now I want to clear it.
var audio = new Audio();
audio.src = "there was some file here";
//now i manually set this to empty string
audio.src = ""
When I debug this, this source actually gets set to the HTML file this is in and not empty string. Why is this happening and what is the right way of removing source from the tag.
Upvotes: 0
Views: 3878
Reputation: 2470
The empty string means an empty relative URL, which resolves to the page itself (the same way <a href="">this page</a>
does).
As suggested by Tobi, you need to remove the attribute entirely to remove the source.
Upvotes: 0