Is calling an ajax function possible before someone's decide to leave the page. I mean i can ask the user if user wants to leave or stay. But i dont know how to alter behaviour when user click "yes leave the page" button.
I have this code working..
<head> <script type="text/javascript"> function catchExit() { return "All your data is going to be lost. Are you sure??"; } </script> </head> <body onbeforeunload="return catchExit()"> <p> Dont leave the page. </p> </body>
confirmbefore it defaults to browser behavior though.