JavaScript onload Event

The onload event in JavaScript triggers when a web page loads in a browser.

Note - The onload Event is defined in BODY element.

JavaScript onload Event Example

Here is an example demonstrates onload event in JavaScript:

   <title>JavaScript onload Event</title>
<body onload="alert('Welcome to JavaScript from!')">

<h3>JavaScript onload Event Example</h3>
<p>You will see an alert box showing an alert message on body load.</p>


Here is the sample output of the above JavaScript onload event example:

javascript onload event

JavaScript Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube