HTML Intro

HTML Intro Quiz

HTML Intro Exercise

HTML Basics

HTML Basic Quiz

HTML Basic Exercise

HTML Advance

HTML Advance Quiz

HTML Advance Exercise

HTML Tags List

HTML Global Attributes

HTML Attributes


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




Its syntax is:- < element onbeforeunload="your_script" >

Code Explanation

All Tutorials related to HTML Attributes

All Sections related to HTML