In this short tutorial, I’m going to show you how to create an exit popup.
If you wish to simply ask the user if they wish to leave you can easily assign a function to the OnBeforeUnload directive. This method will prompt the user every time they attempt to navigate away from the page or close the window.
You can change the wordings within the function and place this function before </head>
Note: This method has been tested with IE8+, FireFox3+, Chrome and Safari 4+.