Show alert on browser close but don't show alert while closing from logoff
<p>In my application when user logs out the browser is closed. And on browser close I am throwing an alert. Now what I want is if I directly close the browser window alert should come but if window is closed through logout alert should not come as I have shown another confirm message of logout.</p>

<pre><code>function closeEditorWarning(){
    for (var i=0;i&lt;childWindow.length;i++) {
        if (childWindow[i] &amp;&amp; !childWindow[i].closed) childWindow[i].close();
        if(i==0) {
            alert("This will close all open e-App applications");
        }
    }
    window.close();  
}
window.onbeforeunload = closeEditorWarning;
</code></pre>

<p>And this is my logout code </p>

<pre><code>    $('#'+id).click(function(event){
        event.preventDefault();
        $('#centerContent').load('&lt;%=request.getContextPath()%&gt;/'+target);
    });
} else {
    $('#'+id).click(function(event){
        event.preventDefault();
        var r=confirm("logout");
        if (r==true)
        {
            flag=true;
            for (var i=0;i&lt;childWindow.length;i++) {
                if (childWindow[i] &amp;&amp; !childWindow[i].closed) childWindow[i].close();
            }
            window.close();
        } else { }
    });
}
</code></pre>
