0

I noticed when trawling the web for an answer that what sounded (to a relative newbie) like the easiest way of acting on a window being exited (window.unload()) was deprecated in a previous version of jQuery. is anyone aware of a (simple) way to do this using either Javascript or jQuery events with the current version of jQuery?

Edit: by this, I mean doing something when the user exits (or tries to exit) the webpage. Sorry for any ambiguity

Mike Cluck
  • 30,526
  • 12
  • 76
  • 90
joeramsay
  • 1
  • 2

1 Answers1

0

You can use window.onbeforeunload like:

window.onbeforeunload = function() {
    return "Bye now!";
};
jontewks
  • 458
  • 3
  • 7