codescracker


javascript

JavaScript onload Event



« Previous Tutorial Next Tutorial »


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:

<!DOCTYPE HTML>
<html>
<head>
	<title>JavaScript onload Event</title>
</head>
<body onload="alert('Welcome to JavaScript from codescracker.com!')">

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

</body>
</html>

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

javascript onload event

« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test