Linked Questions
24 questions linked to/from jquery beforeunload when closing (not leaving) the page?
1 vote
1 answer
3k views
Custom pop-up for 'onbeforeunload' [duplicate]
I've less knowledge on JavaScript/JQuery I got snippet to get alert when i press browser 'X' button. code is below, window.onbeforeunload = function (e) { if(unsavedState){ e = e || window.event; ...
2 votes
1 answer
1k views
Submit a form on browser window close or onbeforeunload [duplicate]
I have a user progress data stored in the form that I submit at regular intervals or on certain sequence or exit button of app. The issue I am facing is if the user navigates through the app and then ...
393 votes
12 answers
440k views
How can I override the OnBeforeUnload dialog and replace it with my own?
I need to warn users about unsaved changes before they leave a page (a pretty common problem). window.onbeforeunload = handler This works but it raises a default dialog with an irritating standard ...
173 votes
17 answers
515k views
How to capture the browser window close event?
I want to capture the browser window/tab close event. I have tried the following with jQuery: jQuery(window).bind( "beforeunload", function() { return confirm("Do you really want ...
59 votes
3 answers
101k views
Dialog box runs for 1 sec and disappears?
I'm running a dialog box upon user leaving the page. The only thing is it runs for 1 sec and disappears? I know it has to do with bind('beforeunload'), but the dialog dies sooner than you can read ...
20 votes
7 answers
85k views
Clear localStorage on tab/browser close but not on refresh
Is there a way to detect tab close event to clear the localStorage. I need localStorage to share data across tabs. window.onbeforeunload event works fine but it has 2 issues for me: It also fires on ...
6 votes
3 answers
13k views
how to detect if a link was clicked when window.onbeforeunload is triggered?
I have window.onbeforeunload triggering properly. It's displaying a confirmation box to ensure the user knows they are navigating (closing) the window and that any unsaved work will be erased. I ...
6 votes
1 answer
8k views
Overriding window.close in Javascript
I am trying to override window.close() Method in JavaScript. Here is my code: (function () { var _close = window.close; window.close = function () { window.opener....
5 votes
3 answers
18k views
Delay Return to Wait for Asynchronous Functions (beforeunload event)
In this coding example the function logout() won't execute all it's async calls and won't wait till they are finished – instead page is unloading before, because the return of the beforeunload event ...
5 votes
2 answers
4k views
Spring MVC Request Interrupted hook
Is there a annotation or something in spring-mvc which lets me call something as soon as a client closes connection or cancels a request in any way? I got a rest service which is normally very quick ...
0 votes
1 answer
4k views
How to find if user selected “Stay” or “Leave” button after beforeunload alert?
I want to logout() user session when user leave website by closing web browser. I am using below code to display alert if user closes browser. Code:- $(window).bind('beforeunload', function () { ...
0 votes
1 answer
3k views
Custom message before leaving a page with current browsers
On a page, I have a complex form (many fields, tabs...) and i want to show an alert message to warn the user if he tries to leave the page, wether he posted the form or not (because in a edit form, ...
1 vote
1 answer
3k views
Don't reset the timeout on refresh
I'm creating online exam kind of application and in my app when user clicks on start button we are going to display timer for 3:00 minutes using setTimeout(func,3*60*1000) but when I refresh the ...
0 votes
2 answers
1k views
Clear Session on browser close in MVC
I am developing as MVC 5 application. I want store the users logout time in database. In my web page i have different Links (@Html.ActionLink). In my controller i have written code to store logout ...
0 votes
0 answers
2k views
call my logout function when browser/tab is closed
In my application I have to forcefully log out user when they close tab or browser.I have logout function and I want to call it when user closes tab/browser.I have tried this piece of code but it didn'...