超酷随鼠标而飞动的时钟--时钟还是走动的 dn001 2009-06-21 08:51:38 <!--要完成此效果需要两个步骤 第一步:把如下代码加入到<head>区域中--> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function formatDate(date) { var mymonth = date.getMonth()+1; var myweekday = date.getDate(); return (mymonth + "月" + myweekday+ "日"); } function printWeek() { var now = new Date(); var nowDayOfWeek = now.getDay(); var nowDay = now.getDate(); var nowMonth = now.getMonth(); var nowYear = now.getYear(); nowYear += (nowYear < 2000) ? 1900 : 0; var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek); var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek)); document.write("当前星期: " + formatDate(weekStartDate) + " - " + formatDate(weekEndDate)); } // End --> </script> <!--第二步:把如下代码加入到<body>区域中--> <script> printWeek(); </script>