how to invoke the function when is loaded the page in javascript code example Example: how to call a function as soon as a page loads javascript <body onload="yourFunction()"> </body>