I am checking when the user closes the browser window, if he says ok, how i do I trigger some action, like opening another window or saving a form. If he chooses "cancel", it should stay in the same page (which is working now). pls share some idea on how to approach this issue
Asked
Active
Viewed 2,410 times
0
-
Possible duplicate: http://stackoverflow.com/questions/4650692/way-to-know-if-user-clicked-cancel-on-a-javascript-onbeforeunload-dialog – Zirak Apr 20 '11 at 05:11
1 Answers
0
You cannot react to the user clicking on the "Leave this page" button. This is by design of the browser: if the user wants to leave, let him go.
If the user chooses to cancel, you can try a technique found in this answer to similar question to execute some custom code like saving changes or the like.