Click here to Skip to main content
14,973,807 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,
I am creating an application in which there is a chat module.Available users are fetched from the database.There is a column in the table table OnlineUsers
in which value is stored in bit.
Now if a user is online it stores 1.Whenever a user logsout an update is made to the table and value is set to 0.

When a user directly closes the browser i want to call a method that updates the table with value 0 so that he is not available in the chat window.
Posted

You can't guarantee it - it is always possible to disconnect a browser from you session without any notification. For example, by turning the PC power off, resetting the ADSL modem, etc.. You can use the Javascript UnLoad event, but I don't think it works the same in all browsers. http://www.w3schools.com/jsref/event_onunload.asp[^]
   
Comments
Manas Bhardwaj 22-Jun-12 6:12am
   
Right +5
   
Comments
Manas Bhardwaj 22-Jun-12 6:12am
   
Good ref +5
Prasad_Kulkarni 22-Jun-12 6:29am
   
Thank you Manas!
use this code it will solve ur problem

XML
<script type="text/javascript">
function unload()
    {

               var btn =document.getElementById('BtnSave');

                 //alert(btn);
                 btn.click();
//        if (Flg==false)
//        {
//            event.returnValue = "UNSAVED DATA WILL BE LOST!!";
//        }
    }
</script>

<body onbeforeunload="unload()">
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900