window.onload

Posted on 2015-04-18 00:45  小蕊同学  阅读(136)  评论(0编辑  收藏  举报
 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="utf-8">
 5     <title></title>
 6     <script>
 7 window.onload=function(){
 8 var hh = document.getElementsByTagName('h1')[0];  //window.onload为在其他的程序全部执行完以后最后执行,如果不加的话只能让输出在<h1>之后
 9 hh.innerHTML = 'cddd';
10 }
11 </script>
12 </head>
13 <body>
14 <h1></h1>
15 </body>
16 </html>
 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="utf-8">
 5     <title></title>
 6 </head>
 7 <body>
 8 <h1></h1>
 9 <script>
10 var hh = document.getElementsByTagName('h1')[0];
11 hh.innerHTML = 'eedd';
12 </script>
13 </body>
14 </html>

 

Copyright © 2024 小蕊同学
Powered by .NET 9.0 on Kubernetes