In JavaScript, I am trying to execute a function 2 seconds after a link is clicked, and wait until the function completes its execution before going to the link destination.
/* JavaScript */
function myFunction() { /* Block of code, with no 'return false'. */ }
<!-- HTML -->
<a onclick="setTimeout(myFunction, 2000);" href="http://www.siku-siku.com">Link</a>
The problem is upon click, the browser immediately goes to the link destination i.e. myFunction
didn't have time to execute. Did I miss anything here?
Thanks beforehand.