How do I call a JavaScript function on page load?


I want to run a function just after the page loads in JavaScript. How can I do that?

1 Answer

4 years ago by

The body tag has an attribute called onload which you can specify the function to run on page load

<body onload="func()">
...
..

</body>
4 years ago by Divya