I have The following in my main javascript file:
window.onbeforeunload = function () {
firstFunction();
}
$("a").live("click", function() {
secondFunction();
}
When user clicks on any link that unloads the page (i.e. navigate to another page), both of those functions get called; FirstFunction() gets called first, then secondFunction() gets called. I want the secondFunction() to get called before the firstFunction();
I was able to achieve this by doing this: setTimeout(‘firstFunction(),100), but I am wondering if there is a better way of doing this?
Thanks.
I suggest you to use mousedown event instead of click.