js简单时钟

 

1,

<html>
<head>
<title>time</title>
</head>

<body >
<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:'Arial black';color:#cccccc;font-size:20px;top:150px;left:233px"></div>
<div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:'Arial black';color:#000000;font-size:20px;top:148px;left:230px"></div>
<script language=javaScript>
<!--
function www_helpor_net() {
thistime= new Date()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
thistime = hours+":"+minutes+":"+seconds

if(document.all) {
bgclocknoshade.innerHTML=thistime
bgclockshade.innerHTML=thistime
}

if(document.layers) {
document.bgclockshade.document.write('<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:Verdana;color:FFAAAAA;font-size:20px;top:10px;left:152px">'+thistime+'</div>')
document.bgclocknoshade.document.write('<div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:Verdana;color:DDDDDD;font-size:20px;top:8px;left:150px">'+thistime+'</div>')
document.close()
}
var timer=setTimeout("www_helpor_net()",200)
}
www_helpor_net();
//-->
</script>

</body>
</html>

 

2.

<html>
<head>
<title>time</title>
</head>

<body >

<span id="liveclock" style"=width: 109px; height: 15px"></span>
<SCRIPT language=javascript>

function www_helpor_net()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()

if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock="现在时刻:<font size='5' face='Arial black'>"+hours+":"+minutes+":"+seconds+"</font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
//-->
</SCRIPT>


</body>
</html>

 

3.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script  language="JavaScript">
<!-- 
var  timerID  =  null;
var  timerRunning  =  false; 
function  stopclock()
{
//  cannot  directly  test  timerID  on  DEC  OSF/1  in  beta  4.
if(timerRunning)
clearTimeout(timerID)
timerRunning  =  false

function  startclock()
{
//  Make  sure  the  clock  is  stopped
stopclock()
showtime()

function  showtime()
{
var  now  =  new  Date()
var  hours  =  now.getHours()
var  minutes  =  now.getMinutes()
var  seconds  =  now.getSeconds()
var  timeValue  =  ""  +  ((hours  >  12)  ?  hours  -  12  :  hours)
timeValue  +=  ((minutes  <  10)  ?  ":0"  :  ":")  +  minutes
timeValue  +=  ((seconds  <  10)  ?  ":0"  :  ":")  +  seconds
timeValue  +=  (hours  >=  12)  ?  "  P.M."  :  "  A.M."
document.clock.face.value  =  timeValue 
timerID  =  setTimeout("showtime()",1000)
timerRunning  =  true
}
//-->
</script>
</head>
<body οnlοad="startclock()">
<form  name="clock"  οnsubmit="0">
<input  type="text"  name="face"  size="14">
</form> 
</body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值