5

Why would you ever want to use $(window).unload(function(){}); over $(window).bind('beforeunload', function(){});

And is there a difference between binding the beforeunload using jQuery like above, and assigning it directly like this: window.onbeforeunload = function() { };

tshepang
  • 12,111
  • 21
  • 91
  • 136
kmb64
  • 1,513
  • 2
  • 17
  • 29
  • This is already answered here: [http://stackoverflow.com/questions/4376596/jquery-unload-or-beforeunload] – Ruben-J Jun 04 '12 at 21:19

1 Answers1

1

Also read this: http://www.quirksmode.org/js/events_events.html#link5

jQuery will always try to use addEventListener before using the 'direct' way (and attachEvent). addEventlistener can cancel bubbling and can attach multiple callbacks.

Sjeiti
  • 2,468
  • 1
  • 31
  • 33