<title>秒表</title><script language="javascript">function showing(){// showFast();setInterval("showTime()",1000);}function showTime() //每一秒刷新一次 {mytime=new Date(); //創造一個時間對象比獲得他的時間元素year=mytime.getYear();date=mytime.getDate();month=mytime.getMonth();day=mytime.getDay();hours=mytime.getHours();minutes=mytime.getMinutes();seconds=mytime.getSeconds();temp="上午好";Astr=new String("");formatTime(hours.minutes,seconds);Astr+=("<font size='+1' color='red'>"+year+"年"+month+"月"+date+"日"+"星期"+(day+1)+"</font>");document.getElementById("lay3").innerHTML=Astr;Bstr="<font size='+1' color='red'>"+temp+hours+":"+minutes+":"+seconds+"</font>";document.getElementById("lay1").innerHTML=Bstr;for(s=0;s<100;++s) //從00到99循環{setTimeout("",10);document.getElementById("lay2").innerText=s;// if(s<10) s="0"+s;// setTimeout("showI(s)",10);// if(s=99)s=0;}}function showI(s){document.getElementById("lay2").innerText=s;}function formatTime(){if(hours!=0&&hours<=7) //決定問候語temp="早上好";else if(hours>7&&hours<11)temp="上午好";else if(hours>=11&&hours<13)temp="中午好";else if(hours>=13&&hours<=18)temp="下午好";else if(hours>18&&hours<24)temp="晚上好"; if(hours<=9)hours="0"+hours; //格式化時間使之以兩位數的格式顯示if(minutes<=9)minutes="0"+minutes;if(seconds<=9)seconds="0"+seconds; } /*function showFast(){for(s=0;s<100;s++){if(s<10) s="0"+s;setTimeout("showI(s)",10);// if(s=99)s=0;}} */</script> <style type="text/css"><!--#lay3 {position:absolute;left:367px;top:134px;width:246px;height:42px;}#Lay1 {position:absolute;left:368px;top:178px;width:182px;height:38px;}#lay2 {position:absolute;left:552px;top:178px;width:63px;height:39px;}--></style></head ><body onload="showing()"><span id="lay3"></span><span id="Lay1"></span><span id="lay2"></span></body></html>
為什么setTimeout(0不能支持1000mm以下的時間呀?還是我的程序有問題?幫我看看是怎么了
慕森卡
2022-11-20 22:18:28