javascript function call timing. The best way of implementing this
<p>I have The following in my main javascript file:</p>

<pre><code>window.onbeforeunload = function () {
    firstFunction();
}

$("a").live("click", function() {
   secondFunction();
}
</code></pre>

<p>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();</p>

<p>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?</p>

<p>Thanks.</p>
