<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> //定义月历函数
function calendar() { var today = new Date(); //创建日期对象
year = today.getYear(); //读取年份
thisDay = today.getDate(); //读取当前日
//创建每月天数数组
var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //如果是闰年,2月份的天数为29天
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29; daysOfCurrentMonth = monthDays[today.getMonth()]; //从每月天数数组中读取当月的天数
firstDay = today;//复制日期对象
firstDay.setDate(1); //设置日期对象firstDay的日为1号
startDay = firstDay.getDay(); //确定当月第一天是星期几
//定义周日和月份中文名数组
var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); var monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); //创建日期对象
var newDate = new Date();
//创建表格
document.write("") document.write("") document.writeln(" | "); } </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>
<BODY onLoad="starttime()" TEXT="#000000" TOPMARGIN="0"> <script language="JavaScript" type="text/javascript"> calendar(); //显示月历
</script> </BODY>
|