How to run a function when the page is loaded?

前端 未结 9 1623
小鲜肉
小鲜肉 2020-11-22 11:02

I want to run a function when the page is loaded, but I don’t want to use it in the tag.

I have a script that runs if I initialise it in th

9条回答
  •  孤城傲影
    2020-11-22 12:09

    As soon as the page load the function will be ran:

    (*your function goes here*)(); 
    

    Alternatively:

    document.onload = functionName();
    window.onload = functionName(); 
    

提交回复
热议问题