Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

loading javascript function on start using javascript

Tags:

javascript

I have this javascript function here for example:

<script type="text/javascript">
  function onLoadFunctions() {
        //some funcitons here...    
  }
</script>

And I wanted to load this function when the page loads using only javascript. Can anyone help me. thanks in advance.

like image 389
Cyan Pile Avatar asked Dec 06 '25 20:12

Cyan Pile


2 Answers

If I understand what you're asking you probably want to use window.onload.

<script type="text/javascript">
  function onLoadFunctions() {
    //some funcitons here...    
  }
  window.onload = onLoadFunctions;
</script>
like image 153
Mark Meyer Avatar answered Dec 09 '25 10:12

Mark Meyer


You can also use body onload event:

<body onload="onLoadFunctions();" ...>
  ...
</body>
like image 30
Kaf Avatar answered Dec 09 '25 11:12

Kaf