saintom 发表于 2004-1-14 18:27:23

From日期带时钟

注释:放在<body****>里

onLoad="startclock();"



注释:放在<body>与</body>之间
<script language="JavaScript">
<!-- Hide
var timerID = null
var timerRunning = false
function MakeArray(size)
{
this.length = size;
for(var i = 1; i <= size; i++)
{
this = "";
}
return this;
}
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false
}
function showtime () {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var day = now.getDay();
Day = new MakeArray(7);
Day="星期天";
Day="星期一";
Day="星期二";
Day="星期三";
Day="星期四";
Day="星期五";
Day="星期六";
var timeValue = "";
timeValue += year + "年";
timeValue += ((month < 10) ? "0" : "") + month + "月";
timeValue += date + "日";
timeValue += (Day) + "";
timeValue += ((hours <= 12) ? hours : hours - 12);
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
timeValue += (hours < 12) ? "上午" : "下午";
document.jsfrm.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true
}
function startclock () {
stopclock();
showtime()
}
//-->

</script>
                  <br>
                  <form name=&#39;jsfrm&#39;>
                  <input type=text name=&#39;face&#39; size=34 value=&#39;&#39;>
                  </form>
页: [1]
查看完整版本: From日期带时钟