1

I am developing online chatting in my website. Some users close the browser when they are in online. I want to done some database operations when user closes the browser

I use this one

 window.onbeforeunload = function (event) {
            event = event || window.event;
            if ((event.clientX < 0) || (event.clientY < 0) || event.clientY < -80) { 
}

it does not work in non IE browsers..........

Can any one help me

AYK
  • 3,312
  • 1
  • 17
  • 30

1 Answers1

0

Refer this question on how to capture the browser close event.

Now what you can do is do an AJAX call in the event to call a Web Service, which in-turn does update your database accordingly.

Refer this question to prevent browser being closed while you are in middle of an AJAX request.

Community
  • 1
  • 1
AYK
  • 3,312
  • 1
  • 17
  • 30