一个显示当前星期的起止日的脚本 - 中国WEB开发者网络 (http://www.webasp.net) -- 网页特效 (http://www.webasp.net/javascript/) --- 一个显示当前星期的起止日的脚本 (http://www.webasp.net/javascript/1/17.htm) |
| -- 发布日期: 2004-05-24 |
| <!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! --> <!-- 要实现此效果需要 2 个步骤: --> <!-- 第 1 步: --> <!-- 把下面的代码加到<HEAD></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> <!-- 第 2 步: --> <!-- 把下面的代码加到<BODY></BODY>区域中: --> <script> printWeek(); </script> |
| webasp.net |