标题:网页中显示当前时间
只看楼主
tml327
Rank: 1
等 级:新手上路
帖 子:510
专家分:0
注 册:2007-10-30
 问题点数:0 回复次数:0 
网页中显示当前时间
<html>
<head>
<title>当前时间</title>
</head>
<!--将以下代码加入HTML的<Body></Body>之间-->
<script language=JavaScript>
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;}
function startclock () {
stopclock();
showtime();}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )
timeValue += ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
document.clock.thetime.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;}
</SCRIPT>
<body onload=startclock()>
<form name=clock >
<input name=thetime style="font-size: 9pt;color:#000000;border:0px none; " size=12>
</form>
</body></html>
搜索更多相关主题的帖子: var 网页 showtime function Body 
2007-12-13 17:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-192289-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.745433 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved