查看: 747|回复: 6
|
HTML里面的时间问题。。
[复制链接]
|
|
这是我用Javascript做出来的,可是问题就出现在这里。。假设我这样做,我的时间只会跟着我refresh才换,我想把它auto走,不用我refresh也是可以走。。
高手帮帮忙。。
<script type = "text/Javascript">
var Today=new Date();
var Day=Today.getDate();
var Month=Today.getMonth() + 1;
var Year=Today.getFullYear();
var Hours=Today.getHours();
var Minutes=Today.getMinutes();
var Seconds=Today.getSeconds();
document.write("Today is " + Day + "/" + Month + "/" + Year + "<br/>");
document.write("Now is " + Hours + ":" + Minutes + " O'clock" + "<br/>");
</script> |
|
|
|
|
|
|
|
发表于 13-4-2006 08:49 PM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 13-4-2006 09:44 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 14-4-2006 12:10 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 14-4-2006 12:14 AM
|
显示全部楼层
你要的是不是他的时间一直在跑的那种
- <SCRIPT language=javascript>
- <!--
- function show5(){if(!document.layers&&!document.all)
- return
- var Digital=new Date()
- var hours=Digital.getHours()
- var minutes=Digital.getMinutes()
- var seconds=Digital.getSeconds()
- var dn="AM"
- if(hours>12){dn="PM"
- hours=hours-12
- }if(hours==0)
- hours=12
- if(minutes<=9)
- minutes="0"+minutes
- if(seconds<=9)
- seconds="0"+seconds
- myclock="<font size='5' face='Arial'><b><font size='1'>Current Time:</font></br>"+hours+":"+minutes+":"
- +seconds+" "+dn+"</b></font>"
- if(document.layers){document.layers.liveclock.document.write(myclock)
- document.layers.liveclock.document.close()
- }else if(document.all)
- liveclock.innerHTML=myclock
- setTimeout("show5()",1000)
- }
- </SCRIPT>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <title>Current Time</title>
- </head>
- <body ONLOAD=show5()>
- <span id=liveclock style=position:absolute;left:10px;top:10px;; width: 109px; height: 15px></span>
- </body>
- </html>
复制代码
[ 本帖最后由 红发 于 14-4-2006 12:18 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 14-4-2006 12:35 AM
|
显示全部楼层
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("show5()",1000)
什么意思?这段看不明!
这写了,时间就会自动变吗? |
|
|
|
|
|
|
|
发表于 14-4-2006 04:57 PM
|
显示全部楼层
<script type = "text/Javascript">
function timer()
{
var Today=new Date();
var Day=Today.getDate();
var Month=Today.getMonth() + 1;
var Year=Today.getFullYear();
var Hours=Today.getHours();
var Minutes=Today.getMinutes();
var Seconds=Today.getSeconds();
document.t.clock.value="Today is " + Day + "/" + Month + "/" + Year + "Now is " + Hours + ":" + Minutes + " :"+Seconds+" O'clock";
}
</script>
</head>
<body onload="setInterval('timer()',1000)">
<form name=t>
<input name="clock" id="clock" style="border:none;width:90%" readonly>
</form>
</body> |
|
|
|
|
|
|
| |
本周最热论坛帖子
|