March 2nd, 2013, 05:24 PM
Alert on Browser's close button click
I need to find browser close button click event in my web application. I need to show some alert message on that event. I tried to do it using window.onbeforeunload event, but it gets called on every page navigation or page refresh
I need to execute that function only on close button click event
March 2nd, 2013, 05:55 PM
don't do it. When you annoy your users with stupid alert messages blocking their whole browser window, you'll prevent nobody from leaving your site, but many will never want to come back.
March 2nd, 2013, 05:59 PM
I think it depends on which browser the client is using. I use this for one of my sites...
<body onbeforeunload="ConfirmClose()" onUnload="ConfirmClose();">