JavaScript loading event (onload)
Loading event (onload)
The event will occur immediately after the page is loaded, and the called program will be executed at the same time.
Note:
When the page is loaded, the onload event is triggered, and the event is written in the <body> tag.
The loading page of this section can be understood as opening a new page.
The following code, when loading a new page, pops up the dialog box "Loading...".
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script> function fun(){ window.alert("加载中......") } </script> </head> <body onload="fun()"> 欢迎来到php.cn </body> </html>