close

<html>
<head>
<script type="text/javascript">
var countdownnumber=5;
var countdownid;
function initial(){ countdownfunc(); }
function countdownfunc(){
var x=document.getElementById("countdown");
x.innerHTML=countdownnumber;
if (countdownnumber==0){
alert("倒數結束");
clearTimeout(countdownid);
}else{
countdownnumber--;
if(countdownid){
clearTimeout(countdownid);
}
countdownid=setTimeout(countdownfunc,1000);
}
}
</script>
</head>
<body onload="initial();">
<p>倒數時間:</p>
<div id="countdown"></div>
</body>
</html>

 

http://www.victsao.com/blog/81-javascript/78-settimeout-timer

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()