用JAVASCIRPT写的一个动态显示日期的函数!
2007-11-27 18:03:46 来源:WEB开发网<script language=JavaScript>
function showtime()
{
var GetTime = new Date();
var Years = GetTime.getYear();
var Months = GetTime.getMonth();
var Days = GetTime.getDate();
var Hours = GetTime.getHours();
var Minutes = GetTime.getMinutes();
var Seconds = GetTime.getSeconds();
var Dn = AM;
if (Hours<=9)
{
Hours=0+Hours;
}
if (Hours==0 || Hours>12)
{
Dn = PM;
}
if (Minutes<=9)
{
Minutes=0+Minutes;
}
if (Seconds<=9)
{
Seconds=0+Seconds;
}
NowTime = Years+年+Months+月+Days+日 +Hours+:+Minutes+:+Seconds+ +Dn;
if (document.layers){
document.layers.liveclock.document.write(NowTime)
document.layers.liveclock.document.close()
}
else if (document.all)
liveclock.innerHTML=NowTime
setTimeout(showtime(),1000)
}
</script>
<table height=50 border=1 align=center width=200>
<tr>
<td bgcolor=#FFCC00 valign=middle>
<font size=2 face=Arial, Helvetica, sans-serif color=black>
<DIV align=center id=liveclock></DIV></font></td>
</tr>
</table>
<script language=JavaScript>
setTimeout(showtime(),1000)
</script>
Tags:JAVASCIRPT 一个 动态
编辑录入:coldstar [复制链接] [打 印]更多精彩
赞助商链接