I have a link which has direct file download URL in it. So when a user click on the link, that file downloads.
Here is the link:
<a class="download-video" href="http://mylink.mp4?file=1&name=A Video"> Download</a>
I was hoping to run some JQuery before this file downloads. I was able to work a solution, but instead of direct downloading, I am redirected to the video. All I want is to download withouth any redirection. This is what I tried:
$('a.download-video').click(function(event) {
var href = this.href;
//My JS Code
alert(href);
event.preventDefault();
window.location = href;
});
Thanks