欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

数字时钟

程序员文章站 2022-03-02 09:29:06
...

<html>
<head>
<title>123</title>
<script language="JavaScript">
function Time(){
if (!document.layers&&!document.all)
return
var Timer=new Date()
var hours=Timer.getHours()
var minutes=Timer.getMinutes()
var seconds=Timer.getSeconds()
var noon="AM"
if (hours>12){
noon="PM"
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here to your desire
myclock="<font size='4' face='Arial' color=blue>"+hours+":"+minutes+":"
+seconds+" "+noon+"</b></font>"
if (document.layers){
document.layers.position.document.write(myclock)
document.layers.position.document.close()
}
else if (document.all)
position.innerHTML=myclock
setTimeout("Time()",1000)
}
</script>
</head>
<body onLoad="Time()">
<span id="position" style="position:absolute;left:441px;top:190px; width: 128px; height: 30px">
</span>
</body>
</html>


运行结果:

[img]/upload/attachment/131307/a43c7037-4413-38a0-b60a-eaf369398e84.jpg[/img]
相关标签: HTML