Prompt before closing the browser tab:
In realtime web applications like shopping websites and multi tab registration websites we wanted to show the confirmation prompt before closing the browser tab. Because user would have clicked the close button by mistake/without knowing.
If we close the tabs without letting him, then he may lost the data’s which he entered.
For example in shopping websites if user is in payment page and he closed the tab without knowledge/by mistake then he need to navigate from first page to payment page again if we would have not asked for the confirmation prompt popup.
Javascript Source code to display the prompt before closing the browser tab:
<script type="text/javascript"> window.onbeforeunload = function (event) { return 'Do you really want to close ?'; } </script>
Output:
Feel free to post your suggestions/comments/feedbacks in comments section below…….