Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[疑难] 这段日历代码,怎么才能给每个日期加上不同的链接啊?

[复制链接]
签约家教 发表于 2010-3-28 06:52:39 | 显示全部楼层 |阅读模式
本帖最后由 签约家教 于 2010-3-28 07:09 编辑

下面这段日历代码,怎么才能给每个日期加上不同的链接,点击每个日期都可以进入不同的链接页面。先谢谢了。
刚才我试了下,藐似这代码SS不能用啊,怎样改才可以用呢?另外,如果这段代码不能用,哪里有SS可以使用的点击每个日期都可以进入不同的链接页面的日历啊。
  1. <HTML>
  2. <HEAD>
  3. <TITLE>豆腐日历</TITLE>
  4. <!-- 请不要删除这段版权信息 -->
  5. <!--
  6. 豆腐制作 都是精品
  7. http://www.asp888.net 豆腐技术站
  8. -->
  9. <STYLE TYPE="text/css">
  10. .normal{BACKGROUND: #ffffff}
  11. .today {font-weight:bold;BACKGROUND: #6699cc}
  12. .satday{color:green}
  13. .sunday{color:red}
  14. .days {font-weight:bold}
  15. </STYLE>
  16. <SCRIPT LANGUAGE="javascript">
  17. //中文月份,如果想显示英文月份,修改下面的注释
  18. /*var months = new Array("January?, "February?, "March",
  19. "April", "May", "June", "July", "August", "September",
  20. "October", "November", "December");*/
  21. var months = new Array("一月", "二月", "三月",
  22. "四月", "五月", "六月", "七月", "八月", "九月",
  23. "十月", "十一月", "十二月");
  24. var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,
  25. 30, 31, 30, 31);
  26. //中文周 如果想显示 英文的,修改下面的注释
  27. /*var days = new Array("Sunday", "Monday", "Tuesday",
  28. "Wednesday", "Thursday", "Friday", "Saturday");*/
  29. var days = new Array("日","一", "二", "三",
  30. "四", "五", "六");
  31. function getDays(month, year) {
  32. //下面的这段代码是判断当前是否是闰年的
  33. if (1 == month)
  34. return ((0 == year % 4) && (0 != (year % 100))) ||
  35. (0 == year % 400) ? 29 : 28;
  36. else
  37. return daysInMonth[month];
  38. }

  39. function getToday() {
  40. //得到今天的年,月,日
  41. this.now = new Date();
  42. this.year = this.now.getFullYear();
  43. this.month = this.now.getMonth();
  44. this.day = this.now.getDate();
  45. }


  46. today = new getToday();

  47. function newCalendar() {

  48. today = new getToday();
  49. var parseYear = parseInt(document.all.year
  50. [document.all.year.selectedIndex].text);
  51. var newCal = new Date(parseYear,
  52. document.all.month.selectedIndex, 1);
  53. var day = -1;
  54. var startDay = newCal.getDay();
  55. var daily = 0;
  56. if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
  57. day = today.day;
  58. var tableCal = document.all.calendar.tBodies.dayList;
  59. var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());
  60. for (var intWeek = 0; intWeek < tableCal.rows.length;intWeek++)
  61. for (var intDay = 0;intDay < tableCal.rows[intWeek].cells.length;intDay++)
  62. {
  63. var cell = tableCal.rows[intWeek].cells[intDay];
  64. if ((intDay == startDay) && (0 == daily))
  65. daily = 1;
  66. if(day==daily)
  67. //今天,调用今天的Class
  68. cell.className = "today";
  69. else if(intDay==6)
  70. //周六
  71. cell.className = "sunday";
  72. else if (intDay==0)
  73. //周日
  74. cell.className ="satday";
  75. else
  76. //平常
  77. cell.className="normal";

  78. if ((daily > 0) && (daily <= intDaysInMonth))
  79. {
  80. cell.innerText = daily;
  81. daily++;
  82. }
  83. else
  84. cell.innerText = "";
  85. }
  86. }

  87. function getDate() {
  88. var sDate;
  89. //这段代码处理鼠标点击的情况
  90. if ("TD" == event.srcElement.tagName)
  91. if ("" != event.srcElement.innerText)
  92. {
  93. sDate = document.all.year.value + "年" + document.all.month.value + "月" + event.srcElement.innerText + "日";
  94. alert(sDate);
  95. }
  96. }
  97. </SCRIPT>
  98. </HEAD>
  99. <BODY ONLOAD="newCalendar()" OnUnload="window.returnValue = document.all.ret.value;">
  100. 豆腐制作,都是精品
  101. <br>
  102. <a href="http://www.asp888.net" targer=_blank>豆腐技术站</a>为大家提供最新最好的技术
  103. <input type="hidden" name="ret">
  104. <TABLE ID="calendar" cellspacing="0" cellpadding="0">
  105. <THEAD>
  106. <TR>
  107. <TD COLSPAN=7 ALIGN=CENTER>
  108. <SELECT ID="month" ONCHANGE="newCalendar()">
  109. <SCRIPT LANGUAGE="javascript">
  110. for (var intLoop = 0; intLoop < months.length;
  111. intLoop++)
  112. document.write("<OPTION VALUE= " + (intLoop + 1) + " " +
  113. (today.month == intLoop ?
  114. "Selected" : "") + ">" +
  115. months[intLoop]);
  116. </SCRIPT>
  117. </SELECT>

  118. <SELECT ID="year" ONCHANGE="newCalendar()">
  119. <SCRIPT LANGUAGE="javascript">
  120. for (var intLoop = today.year-50; intLoop < (today.year + 4);
  121. intLoop++)
  122. document.write("<OPTION VALUE= " + intLoop + " " +
  123. (today.year == intLoop ?
  124. "Selected" : "") + ">" +
  125. intLoop);
  126. </SCRIPT>
  127. </SELECT>
  128. </TD>
  129. </TR>
  130. <TR CLASS="days">
  131. <SCRIPT LANGUAGE="javascript">

  132. document.write("<TD class=satday>" + days[0] + "</TD>");
  133. for (var intLoop = 1; intLoop < days.length-1;
  134. intLoop++)
  135. document.write("<TD>" + days[intLoop] + "</TD>");
  136. document.write("<TD class=sunday>" + days[intLoop] + "</TD>");
  137. </SCRIPT>
  138. </TR>
  139. </THEAD>
  140. <TBODY border=1 cellspacing="0" cellpadding="0" ID="dayList"ALIGN=CENTER ONCLICK="getDate()">
  141. <SCRIPT LANGUAGE="javascript">
  142. for (var intWeeks = 0; intWeeks < 6; intWeeks++) {
  143. document.write("<TR style='cursor:hand'>");
  144. for (var intDays = 0; intDays < days.length;
  145. intDays++)
  146. document.write("<TD></TD>");
  147. document.write("</TR>");
  148. }
  149. </SCRIPT>
  150. </TBODY>
  151. </TABLE>
  152. <center><Input Style="width:50pt" type=button value="Cancel" OnClick="Cancel();"></center>
  153. </BODY>
  154. </HTML>

  155. <Script Language="javascript1.2">

  156. function Cancel() {
  157. document.all.ret.value = "";
  158. window.close();
  159. }

  160. </script>
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-17 13:26 , Processed in 0.020312 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表