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
  • 369,052
  • 73
  • 620
  • 1,021
user580950
  • 3,355
  • 12
  • 46
  • 88

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
  • 2,911
  • 3
  • 28
  • 40
0

Well, try onbeforeunload (Microsoft thingy)

$(window).bind("onbeforeunload", function(){
    alert('Bye now!');
});
genesis
  • 49,367
  • 20
  • 94
  • 122