0 Replies Latest reply on Jul 7, 2010 11:38 PM by IndPeter

    how to do cleanup action when browser closed.

    IndPeter

      hi all,

       

      we have an user table in db and it has the column like 'isUserloggedin'. we update this column with 'y' when the user logged in and with 'n' when the user hits logout button. we are facing problem when the user close the browser and not using the logout button.

       

      so what we did introduing some java script in the .html file which loads the swf file.

       

      the codes are below..

       

      <script language="JavaScript">
          window.onbeforeunload=showAlert;
          var loginUSerName="";
         
          function showAlert(){       
              if(loginUSerName.length > 0){
                  getFlexApp("AME").browserClosed();
                  var message="U r logged in as ";
                  var message2=". Do you want to close the browser?";
                  return (message.concat(loginUSerName,message2));       
              }
             
          }
         
          function setloginUsername(username){
              loginUSerName=username;
          }
         
         
          function getFlexApp(appName) {

       

            if (navigator.appName.indexOf ("Microsoft") !=-1) {
              return window[appName];
              alert(appName);
            }else {
              return document[appName];
           } 
          }
      </script>

       

      in the mxml file

      during creation complete

      if(ExternalInterface.available){
                          ExternalInterface.addCallback("browserClosed",updateSupportUSerTableFn);
                      }

       

      private function updateSupportUSerTableFn():void{
                      updateSupportTablefn("n","y");
                      broadCastLogoutMsg(eliminateDuplicateInArray(chatWindowOpenUsers));
                  }

       

      during login

      if(ExternalInterface.available){
                              ExternalInterface.call("setloginUsername","username");
                          }

       

      during logout

      if(ExternalInterface.available){
                          ExternalInterface.call("setloginUsername","");
                      }

       

      the above code will help to prompt the popup with the message, "OK" and "Cancel" buttons,when the user close the browser.

       

      i want to do this cleanup action when the user press "OK" and not to do this when the user press cancel and stay on.

       

      is there any way to do this.

       

      Thanks in advance