There are many situations where we want user to complete certain process before page refresh or page unload or warn user before closing the browser window, for that we show certain warnings or confirmation box to front end user.
Following code will show similar confirmation box which will say:
“This page is asking you to confirm that you want to leave – data you have entered may not be saved.”. with “Leave page” and “Stay on Page” buttons.
The code is cross browser compitable and works well with IE >= 7, Chrome, Firefox.