I think the most reasonable way to handle this is to disable the link after clicking it, and then turn it back on when the function is launched. Assuming you have jQuery, something like ...
$('#button').click(function () { $(this).attr("disabled", "true"); doTheFunction(); $(this).attr("disabled", "false"); });
If you really need to wait a certain amount of time after calling the function, you can use setTimeout to reuse the button.
$('#button').click(function () { $(this).attr("disabled", "true"); doTheFunction(); var btn = $(this); setTimeout(function () { btn.attr("disabled", "false"); }, 5000);
EDIT: (for comments below)
For reference, I would simulate above by adding and removing a class, since you're right there is no attribute disabled.
$('#link').click(function () { if ($(this).hasClass('disabled_link')) { return; } $(this).addClass("disabled_link"); doTheFunction(); var link = $(this); setTimeout(function () { link.removeClass("disabled_link"); }, 5000);
source share