how to run js function when page is loaded 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>