document.writeln("< /TR>< TR>");
//显示每月前面的"空日" column = 0; for (i=0; i document.writeln("\n< TD>< FONT STYLE='font-size:9pt'> < /FONT>< /TD>"); column++; }
//如果是当前日就突出显示(红色),否则正常显示(黑色) for (i=1; i<=daysOfCurrentMonth; i++) { if (i == thisDay) { document.writeln("< /TD>< TD ALIGN='CENTER'>< FONT STYLE='font-size:9pt;Color:#ff0000'>< B>") } else { document.writeln("< /TD>< TD BGCOLOR='#88FF99' ALIGN='CENTER'>< FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#000000'>"); } document.writeln(i); if (i == thisDay) document.writeln("< /FONT>< /TD>") column++; if (column == 7) { document.writeln("< TR>"); column = 0; } } document.writeln("< TR>< TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>") document.writeln("< FORM NAME='time' onSubmit='0'>< FONT STYLE='font-size:9pt;Color:#ffffff'>")
//显示当前时间 document.writeln("当前时间:< INPUT TYPE='Text' NAME='textbox' ALIGN='TOP'>< /FONT>< /TD>< /TR>< /TABLE>") document.writeln("< /TD>< /TR>< /TABLE>< /FORM>"); } < /SCRIPT>
< SCRIPT LANGUAGE="javascript"> //初始化控制变量 var timerID = null; var timerRunning = false;
//定义时间显示函数 function stoptime (){ if(timerRunning) clearTimeout(timerID); timerRunning = false;}
//定义显示时间函数 function showtime () { var newDate = new Date(); var hours = newDate.getHours(); var minutes = newDate.getMinutes(); var seconds = newDate.getSeconds() var timeValue = " " + ((hours >12) ? hours -12 :hours) timeValue += ((minutes < 10) ? ":0" : ":") + minutes timeValue += ((seconds < 10) ? ":0" : ":") + seconds timeValue += (hours >= 12) ? " 下午 " : " 上午 " document.time.textbox.value = timeValue; timerID = setTimeout("showtime()",1000);//设置超时,使时间动态显示 timerRunning = true;}
//显示当前时间 function starttime () { stoptime(); showtime();} < /SCRIPT>
(2)在HTML文档正文< body>...< /body>中插入javascript脚本,并给< body>标记添加一些属性:
< BODY onLoad="starttime()" TEXT="#000000" TOPMARGIN="0"> < script language="javascript" type="text/javascript"> calendar(); //显示月历 < /script> < /BODY>
|