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

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
joeramsay
  • 1
  • 2

1 Answers1

0

You can use window.onbeforeunload like:

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