How do I call a JavaScript function on page load?

If you want the onload method to take parameters, you can do something similar to this: This binds onload to an anonymous function, that when invoked, will run your desired function, with whatever parameters you give it. And, of course, you can run more than one function from inside the anonymous function.[

Javascript onload not working

I am using an external javascript file, which I am using to store all my javascript functions in. Next I am trying to call a function from the body, using the next line of code: The only thing that this function does is making an alert box pop up, well that’s what’s it supposed to … Read more

How to execute AngularJS controller function on page load?

On the one hand as @Mark-Rajcok said you can just get away with private inner function: Also you can take a look at ng-init directive. Implementation will be much like: But take care about it as angular documentation implies (since v1.2) to NOT use ng-init for that. However imo it depends on architecture of your app. I used ng-init when I wanted to … Read more