how to add function on page load in javascript code example
Example 1: how to call a function as soon as a page loads javascript
<body onload="yourFunction()"> </body>
Example 2: javascript execute code on page load
<html>
<body onload="loaded();"></body>
<script>
function loaded() {
alert('Page is loaded');
}
</script>
</html>