HTML onbeforeunload Attribute
HTML onbeforeunload Attribute
The onbeforeunload event fires when the document is about to be unloaded. It allows us to display a message in a confirmation dialog box to inform the user whether they want to stay or leave the current page.
The default message that appears in the confirmation box varies in different browsers.
Used With:-
Elements | Event |
---|---|
body | onbeforeunload |
Syntax:-
Its syntax is:- < element onbeforeunload="your_script" >