定时器
<body>
<input type="button" value="显示定时的警告框" onClick = "timedMsg()">
<p id="time">请点击上面的按钮。警告框会在 5 秒后显示。</p>
<script type="text/javascript">
var index = 5;
function timedMsg(){
var t= document.getElementById("time");
t.innerHTML = "警告框会在 "+index+" 秒后显示。";
index --;
if(index < 0){
setTimeout("alert('hello boy!')",1)
}else{
setTimeout("timedMsg()",1000)
}
}
</script>
</body>