Pap
Pap

Reputation: 215

Jquery unload is not working

I have problem with jquery unload. It Doesn't WORK !

JS code :

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

HTML :

<a href="http://google.com">Google</a>

jsfiddle : http://jsfiddle.net/RVuU7/

Upvotes: 3

Views: 2313

Answers (2)

kei
kei

Reputation: 20491

Use this instead

 window.onbeforeunload = function () {
     alert("Goodbye!");
 };

Upvotes: 3

Vandesh
Vandesh

Reputation: 6894

Try

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

instead.
Here's the fiddle - http://jsfiddle.net/v3J5t/
According to the .unload() documentation , it was deprecated in JQuery 1.8

Upvotes: 3

Related Questions