Using window.onbeforeunload, is it possible to know which event has occurred?
<p>How does one determine what is the trigger of an event (close browser, close tab, redirect on other page etc.)? </p>

<pre><code>function winUnload(){
     var pathToCloseCurrentTab = window.location.protocol + "//" + window.location.host + '&lt;%= ResolveUrl("~/Services/SenderAjax.asmx") %&gt;' + "/CloseCurrentTab";         
        $.ajax({
                type: 'POST',
                url: pathToCloseCurrentTab,
                dataType: 'JSON',
                data: {'data': $('input[id$=hfTimeLoadLayOut]').val()}
            });
}
window.onbeforeunload= function (evt){                    
    winUnload();
};
</code></pre>
