Run function if user close browser
<p>I have problem with this function. I will explain - 
I must execute function if user closes browser. This function is write in JavaScript- saveCookieScriptPrefOnLogOut().</p>

<p>I have this solutions (I writed this using info from StackOverFlow):</p>

<pre><code>var inFormOrLink;
$('a').live('click', function() { inFormOrLink = true; });
$('form').bind('submit', function() { inFormOrLink = true; });

$(window).bind('beforeunload', function(eventObject) {
var returnValue = undefined;
if (! inFormOrLink) {
    saveCookieScriptPrefOnLogOut();
}
saveCookieScriptPrefOnLogOut();
return true;
});
</code></pre>

<p>Problems with this solution is: every browser display windows with question "Do you really want to close?"</p>

<p>I have to hide this information/window. Second problem (less important but still) - FF and IE runs this function when I click on Link or form submit. I need to ignore a links and form submit.</p>

<p>solution must be crossbrowser solution (IE, Chrome, FF on windows. The most important is IE). I can use PHP and javascript.</p>

<p>Can you give me any answer how I solve these problems?</p>
