JavaScript Program to Call a Function After Loading a WebPage

Write a JavaScript program call a function after loading a webpage using onload() event.



Source Code
<html>
<head>
    <title>Onload Demo</title>
    <script>
        function sayHello() 
        {
            alert("Hii");
        }
    </script>
</head>
<body onload="sayHello()">
<p>This is an example of onload function.</p>
</body>
</html>
Output





"Coding Hub - Learn to code" app now available on Google Play Store