DHTML_____window对象的事件

<html>
<head>
  <meta charset="utf-8">
  <title>window对象事件</title>
</head>

<body onload="alert('欢迎')" onunload="alert('再见')" onbeforeunload="window.event.returnValue='请小心行事!'">
 <!--onbeforeunload 包括刷新和关闭窗口-->
<div id="scrollDiv"></div>

<input type="button" onclick="clearInt()" value="Cancel"/>

<script language="javascript">
//01 onload
//02 onunload
//03 onbeforeunload
var set=setInterval("demo()",2000);

var str="";
function demo(){
    var div=document.getElementById("scrollDiv");
    str+="欢迎光临<br/>";
    div.innerHTML=str;
}
function clearInt(){
    window.clearInterval(set);
}
//05 onclick

//06 onmouseover onmouseout  onmousemove 

//07 onmousedown onmouseup

//08 onkeydown onkeyup onkeypress

</script>
</body>
</html>
View Code
 1 <html>
 2 <head>
 3   <meta charset="utf-8">
 4   <title>window对象事件</title>
 5 </head>
 6 
 7 <body onload="alert('欢迎')" onunload="alert('再见')" onbeforeunload="window.event.returnValue='请小心行事!'">
 8  <!--onbeforeunload 包括刷新和关闭窗口-->
 9 <div id="scrollDiv"></div>
10 
11 <input type="button" onclick="clearInt()" value="Cancel"/>
12 
13 <script language="javascript">
14 //01 onload
15 //02 onunload
16 //03 onbeforeunload
17 var set=setInterval("demo()",2000);
18 
19 var str="";
20 function demo(){
21     var div=document.getElementById("scrollDiv");
22     str+="欢迎光临<br/>";
23     div.innerHTML=str;
24 }
25 function clearInt(){
26     window.clearInterval(set);
27 }
28 //05 onclick
29 
30 //06 onmouseover onmouseout  onmousemove 
31 
32 //07 onmousedown onmouseup
33 
34 //08 onkeydown onkeyup onkeypress
35 
36 </script>
37 </body>
38 </html>

 

posted @ 2016-11-18 17:20  奋斗的少年WH  阅读(312)  评论(0编辑  收藏  举报