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:
- 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.
- The window.onload traditional registration event can only be written once, if there are more than one, the last window.onload will prevail.
- There is no limit if addEventListener is used.