I have a download link, and after the user downloads it I want to remove the link to the download and change the text. I was able to get that going, but it does it so fast that the user would be unable to download the exe file. If I somehow delayed it would that be an solution? Is there a better way to do what I'm doing?
Here's my JS
function removeLink(){
try{
$('#downloadLink').text("Thank You For Downloading This Software!");
$('#downloadLink').attr('href', 'javascript:void(0)');
}
catch(err){
alert(err.message);
}
}
link
<a href="download.exe" title="Download" id="download" onclick="removeLink()">Download</a>
Also I know it's not a very 'secure' way of doing it since I'm just using javascript for it, but this is mostly just for the average user.
Something like this?
$('#downloadLink').click(function() {
$(this).replaceWith('<span>Thanks for downloading...</span>');
});
If you still have issues with it not working, put a window.location = 'download.exe';
at the top of the click function.
So - knowing its not a secure method - what's wrong with:
$('a').on('click', function() {
$(this).text('Thank You For Downloading This Software!').removeAttr('href');
});
Change the selector to whatever is applicable instead of $('a')
You may not want function removeLink() becuase you are not calling it. Instead use
$(document).ready(){
});
And also for your time out issue...
use jQuery's delay()
Another thing is that you are calling #downloadLink... Don't forget to add the ID to the tag.
EDIT: As the others are saying you may just want to do the entire function in jQuery.