I am downloading a file through the link and want to process JS before the link download. Through JS, I am showing modal within which, if a person agrees, the link should have the file downloaded, and if a person disagrees, the file shouldn't download.
Below is how I tried. I want it to stop till the user press Yes/No and then it proceeds to either download or not.
Is there a way to do this through JS?
Link:-
<a class="download-video" href="http://mylink.mp4?file=1&name=A Video" download> Download</a>
This is what I tried from this question:-
$('a.download-video').click(function(event) {
var href = this.href;
e.preventDefault(); //stop the browser from following
window.location.href = href;
});