关闭

js简单时钟

标签: javascriptfunctiondatedivhtmltimer
1773人阅读 评论(0) 收藏 举报
分类:

 

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 onload="startclock()">
<form  name="clock"  onsubmit="0">
<input  type="text"  name="face"  size="14">
</form> 
</body>

</html>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:35670次
    • 积分:440
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:18篇
    • 译文:0篇
    • 评论:5条
    文章分类
    文章存档
    最新评论