0

According to w3school The unload() method was deprecated in jQuery version 1.8 and removed in version 3.0. and these code not worl also

$(window).unload(function(){
    alert("Goodbye!");
});

any new method for doing that task please help me this is example code i am building live chat application when user close browser update value to database

Malik Umer
  • 64
  • 2
  • 9

2 Answers2

0

Use pure javascript code not jquery to achieve that.

window.onbeforeunload=function(){
alert("Good Bye");
}
Osama
  • 2,912
  • 1
  • 12
  • 15
0

Try this one:

window.onbeforeunload = function(){
    return "Bye now!";
};
IceCode
  • 1,466
  • 13
  • 22