HTML onbeforeunload Event Attribute
The onbeforeunload event runs when the document is about to be unloaded, thus, allowing to display message in a dialog box to inform the user whether a user wants to stay or leave the current page, i.e., this event triggers just before a user leaves a webpage, and helps to prevent an accidental clos