Show alert on browser close but don't show alert while closing from logoff
- by Neha Jain
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.
                  function closeEditorWarning(){
     for (var i=0;i<childWindow.length;i++) {
           if (childWindow[i] && !childWindow[i].closed) childWindow[i].close();
                if(i==0)
                   {
                 alert("This will close all open e-App applications");
                 }
                     }
        window.close();  
                       }
              window.onbeforeunload = closeEditorWarning;
And this is my logout code 
              $('#'+id).click(function(event){
                        event.preventDefault();
                                                $('#centerContent').load('<%=request.getContextPath()%>/'+target);
                    });
                }   
                else 
                {
                $('#'+id).click(function(event){
                        event.preventDefault();
                        var r=confirm("logout");
                       if (r==true)
                       {
                           flag=true;
                              for (var i=0;i<childWindow.length;i++) {
                                    if (childWindow[i] && !childWindow[i].closed)
                                        childWindow[i].close();
                                  } 
                             window.close();
                             }
                      else
                         {
                         }
                    });
                }