js window loading event

window.onload = function(){
    
    }
或者
window.addEventListener("load",function(){
    
    })

window.onload is a window (page) loading event, which is triggered when the document content is completely loaded (including images, script files, CSS files, etc.), and it is called a processing function.
Note:

  1. With window.onload, you can write the JS code above the page elements, because onload waits for the page content to be fully loaded before executing the processing function.
  2. The window.onload traditional registration event can only be written once, if there are more than one, the last window.onload will prevail.
  3. There is no limit if addEventListener is used.

Guess you like

Origin blog.csdn.net/Guoxuxinwen/article/details/104654871