【javascript】【1】html文档完全加载后再运行特定初始化javascript代码

 1 <!DOCTYPE html> 
 2 <html>
 3 <head>
 4     <title>page init</title>
 5     <script>
 6         function init()
 7         {
 8             alert("init on load");
 9         }
10         
11         window.onload = init;
12     </script>
13 </head>
14     
15 <body>
16     <h1>init page on load</h1>
17 </body>
18     
19 </html>

整个html文档加载后运行init函数代码段。这样就可以针对html结构进行初始化

原文地址:https://www.cnblogs.com/qiudeqing/p/3131371.html