How do I call a JavaScript function on page load?

后端 未结 8 1518
轮回少年
轮回少年 2020-11-22 15:18

Traditionally, to call a JavaScript function once the page has loaded, you\'d add an onload attribute to the body containing a bit of JavaScript (usually only c

8条回答
  •  鱼传尺愫
    2020-11-22 15:28

    You have to call the function you want to be called on load (i.e., load of the document/page). For example, the function you want to load when document or page load is called "yourFunction". This can be done by calling the function on load event of the document. Please see the code below for more detail.

    Try the code below:

    
    
    

提交回复
热议问题