Unload Problem in IE 9.0

I use the following code to test onunload event in jQuery

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

It works fine on FF, CHROME, but does not display a warning in IE9 when the window is closed. Any workaround?

+3
source share
2 answers

You can use beforeunload

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

But be careful if you need to submit a form to this page: How to capture a browser window closing event?

0
source

Well, try onbeforeunload (Microsoft thingy)

$(window).bind("onbeforeunload", function(){
    alert('Bye now!');
});
0
source

All Articles