Javascript Onload Event Example

Apr 12, 2021 . Admin

Hello Friends,

Now let's see example of how to use javascript onload event example. This is a short guide on onload event. Here you will learn how to use javascript onload event. We will use how to use if onload event in javascript. Let's get started with how to onload event in javascript.

Here i will give you many example how you can check javascript onload event.

Example: 1
<!DOCTYPE html>
<html>
<head>
   <title>Javascript - How to check if onload event?-MyWebtuts.com</title>
</head>

	<h2>Onload Function</h2>

	<body onload="onloadFunc()">

	<script>
		function onloadFunc() {
		  	alert("Page is loaded");
		}
	</script>

	</body>
</html>
Output: 1
    Page is loaded
Example: 2
<!DOCTYPE html>
<html>
	<head>
	   <title>Javascript - How to check if onload event?-MyWebtuts.com</title>
	</head>

	<body onload="console.log('Loaded by onload function!')">
		
		<h2>Onload Function</h2>

	</body>
	
</html>
Output: 2
    Loaded by onload function!

It will help you....

#Javascript