Prompt before closing the browser tab example

confirmation prompt before closing the browser tab

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.

demo

 

download

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:

Prompt before closing the browser tab example demo

Feel free to post your suggestions/comments/feedbacks in comments section below…….

Leave a Reply