3

I am using the following code to check onunload event in Jquery

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

It works great on FF, CHROME, but doesnt display the alert on IE9 when the window is closed. Any workaround ?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
user580950
  • 3,558
  • 12
  • 49
  • 94

2 Answers2

0

You can use beforeunload

$(window).bind("beforeunload", function() { alert("Bye now!"); });

But be careful if you need to submit a form on that page: How to capture the browser window close event?

Community
  • 1
  • 1
nthpixel
  • 3,041
  • 3
  • 30
  • 42
0

Well, try onbeforeunload (Microsoft thingy)

$(window).bind("onbeforeunload", function(){
    alert('Bye now!');
});
genesis
  • 50,477
  • 20
  • 96
  • 125