browser-close

Sending ajax when user closes browser window [duplicate]

試著忘記壹切 提交于 2021-01-27 12:43:58
问题 This question already has answers here : JavaScript, browsers, window close - send an AJAX request or run a script on window closing (9 answers) Closed 4 years ago . My Main GOAL and actual scenario: If two users share the same credentials, then the second user can not login into the system until the first one who is already logged in, log outs system. Actually I want to set login_flag=0 on server database, when user closes the browser window. I googled and figured out to send an ajax request

Notify user on browser close only

China☆狼群 提交于 2019-12-18 05:26:30
问题 I am trying to implement notifying when the user closes or reloades the page.Crrently i am using the following code function unloadPage(){ return "Your changes will not be saved."; } window.onbeforeclose = unloadPage; This works fine.But the problem is this happens whenever a navigation takes place.That is either a page refresh or a form submission or a hyperlink click or whatever navigation takes place..I just want to work this code only for browser refreshing and closing.I knew about

Browser refresh using OnBeforeUnload event

扶醉桌前 提交于 2019-12-06 06:43:43
问题 On the web page when the user clicks on the logout button, I have a JavaScript function which clears the user session which is stored on the MongoDB. It works fine. Also I would like to clear the user session when the user closes the browser. Here is the issue I am facing : when the user clicks on the refresh icon the logout function is getting called. I only want this function to be called when the browser is closed. Can I prevent this function from calling on the page refresh? My logic here

Browser refresh using OnBeforeUnload event

有些话、适合烂在心里 提交于 2019-12-04 10:42:55
On the web page when the user clicks on the logout button, I have a JavaScript function which clears the user session which is stored on the MongoDB. It works fine. Also I would like to clear the user session when the user closes the browser. Here is the issue I am facing : when the user clicks on the refresh icon the logout function is getting called. I only want this function to be called when the browser is closed. Can I prevent this function from calling on the page refresh? My logic here is to clean up the session when the browser is closed. I am deleting the session which is on MongoDB.

Prompt User before browser close?

好久不见. 提交于 2019-11-27 20:09:56
We have an administrative portal that our teachers constantly forget to download their latest PDF instructions before logging out and/or closing the browser window. I have looked around but can't find what I'm looking for. I want to accomplish the following goals: Goal 1 Before a user can close the browser window, they are prompted "Did you remember to download your form?" with two options, yes/no. If yes, close, if no, return to page. Goal 2 Before a user can click the 'logout' button, they are prompted with the same as above. My first pass at the very basic code (which does not work for

Prompt User before browser close?

馋奶兔 提交于 2019-11-26 20:13:25
问题 We have an administrative portal that our teachers constantly forget to download their latest PDF instructions before logging out and/or closing the browser window. I have looked around but can't find what I'm looking for. I want to accomplish the following goals: Goal 1 Before a user can close the browser window, they are prompted "Did you remember to download your form?" with two options, yes/no. If yes, close, if no, return to page. Goal 2 Before a user can click the 'logout' button, they