<Script LANGUAGE="JavaScript">
 var months = new Array("一", "二", "三","四", "五", "六", "七", "八", "九","十", "十一", "十二");
 var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31);
 var days = new Array("SUN","MON", "TUE", "WED","THU", "FRI", "SAT");
 var classTemp;
 var today=new getToday();
 var year=today.year;
 var month=today.month;
 var newCal;  function getDays(month, year) {
  if (1 == month) return ((0 == year % 4) && (0 != (year % 100))) ||(0 == year % 400) ? 29 : 28;
  else return daysInMonth[month];
 } function getToday() {
  this.now = new Date();
  this.year = this.now.getFullYear();
  this.month = this.now.getMonth();
  this.day = this.now.getDate();
 } function Calendar() {
  newCal = new Date(year,month,1);
  today = new getToday();   
  var day = -1;
  var startDay = newCal.getDay();
  var endDay=getDays(newCal.getMonth(), newCal.getFullYear());
  var daily = 0;
  if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
  {
   day = today.day;
  }
  var caltable = document.all.caltable.tBodies.calendar;
  var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());  for (var intWeek = 0; intWeek < caltable.rows.length;intWeek++)
   for (var intDay = 0;intDay < caltable.rows[intWeek].cells.length;intDay++)
   {
    var cell = caltable.rows[intWeek].cells[intDay];
    var montemp=(newCal.getMonth()+1)<10?("0"+(newCal.getMonth()+1)):(newCal.getMonth()+1);         
    if ((intDay == startDay) && (0 == daily)){ daily = 1;}
    var daytemp=daily<10?("0"+daily):(daily);
    var d="<"+newCal.getFullYear()+"-"+montemp+"-"+daytemp+">";
    if(day==daily) cell.className="DayNow";
    else if(intDay==6) cell.className = "DaySat";
    else if (intDay==0) cell.className ="DaySun";
    else cell.className="Day";
    
    if ((daily > 0) && (daily <= intDaysInMonth))
    {
     cell.innerText = daily;
     cell.onclick=function(){document.location.href="http://www.csdn.net?selectedDate="+document.getElementById("year").value+document.getElementById("month").value+this.innerText}
     daily++;
    } else
    {
     cell.className="CalendarTD";
     cell.innerText = "";
    }
  }
  document.all.year.value=year;
  document.all.month.value=month+1;
 } function subMonth()
 {
  if ((month-1)<0)
  {
   month=11;
   year=year-1;
  } else
  {
   month=month-1;
  }
  Calendar();
 } function addMonth()
 {
  if((month+1)>11)
  {
   month=0;
   year=year+1;
  } else
  {
   month=month+1;
  }
  Calendar();
 } function setDate() 
 {
  if (document.all.month.value<1||document.all.month.value>12)
  {
   alert("Input error!");
   return;
  }
  year=Math.ceil(document.all.year.value);
  month=Math.ceil(document.all.month.value-1);
  Calendar();
 }
</Script><Style>
Input {font-family: verdana;font-size: 9pt;text-decoration: none;background-color: #FFFFFF;height: 20px;border: 1px solid #666666;color:#000000;}.Calendar {font-family: verdana;text-decoration: none;width: 170;background-color: #C0D0E8;font-size: 9pt;border:0px dotted #1C6FA5;}
.CalendarTD {font-family: verdana;font-size: 7pt;color: #000000;background-color:#f6f6f6;height: 20px;width:11%;text-align: center;}.Title {font-family: verdana;font-size: 11pt;font-weight: normal;height: 24px;text-align: center;color: #333333;text-decoration: none;background-color: #A4B9D7;border-top-width: 1px;border-right-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-bottom-style:1px;border-top-color: #999999;border-right-color: #999999;border-bottom-color: #999999;border-left-color: #999999;}.Day {font-family: verdana;font-size: 7pt;color:#243F65;background-color: #E5E9F2;height: 20px;width:201%;text-align: center;}
.DaySat {font-family: verdana;font-size: 7pt;color:#FF0000;text-decoration: none;background-color:#E5E9F2;text-align: center;height: 18px;width: 20%;}
.DaySun {font-family: verdana;font-size: 7pt;color: #FF0000;text-decoration: none;background-color:#E5E9F2;text-align: center;height: 18px;width: 20%;}
.DayNow {font-family: verdana;font-size: 7pt;font-weight: bold;color: #000000;background-color: #FFFFFF;height: 20px;text-align: center;}.DayTitle {font-family: verdana;font-size: 9pt;color: #000000;background-color: #C0D0E8;height: 20px;width:11%;text-align: center;}
.DaySatTitle {font-family: verdana;font-size: 9pt;color:#FF0000;text-decoration: none;background-color:#C0D0E8;text-align: center;height: 20px;width: 20%;}
.DaySunTitle {font-family: verdana;font-size: 9pt;color: #FF0000;text-decoration: none;background-color: #C0D0E8;text-align: center;height: 20px;width: 20%;}.DayButton {font-family: Webdings;font-size: 9pt;font-weight: bold;color: #243F65;cursor:hand;text-decoration: none;}</Style>
<table border="0" cellpadding="0" cellspacing="1" class="Calendar" id="caltable">
<thead>
     <tr align="center" valign="middle"> 
  <td colspan="7" class="Title">
   <a href="javaScript:subMonth();" title="up" Class="DayButton">3</a> <input name="year" type="text" size="4" maxlength="4" onkeydown="if (event.keyCode==13){setDate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"  onpaste="this.value=this.value.replace(/[^0-9]/g,'')"> -- <input name="month" type="text" size="1" maxlength="2" onkeydown="if (event.keyCode==13){setDate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"  onpaste="this.value=this.value.replace(/[^0-9]/g,'')">  <a href="JavaScript:addMonth();" title="down" Class="DayButton">4</a>
  </td>
 </tr>
 <tr align="center" valign="middle"> 
  <Script LANGUAGE="JavaScript">  
   document.write("<TD class=DaySunTitle id=diary >" + days[0] + "</TD>"); 
   for (var intLoop = 1; intLoop < days.length-1;intLoop++) 
    document.write("<TD class=DayTitle id=diary>" + days[intLoop] + "</TD>"); 
    document.write("<TD class=DaySatTitle id=diary>" + days[intLoop] + "</TD>"); 
  </Script>
 </TR> 
</thead>
<TBODY border=1 cellspacing="0" cellpadding="0" ID="calendar" ALIGN=CENTER >
 <Script LANGUAGE="JavaScript">
  for (var intWeeks = 0; intWeeks < 6; intWeeks++)
  {
   document.write("<TR style='cursor:hand'>");
   for (var intDays = 0; intDays < days.length;intDays++) 
   document.write("<TD class=CalendarTD ></TD>");
   document.write("</TR>");
  } 
 </Script>
</TBODY>
</TABLE>
<Script  LANGUAGE="JavaScript">
 Calendar();
</Script>

解决方案 »

  1.   

    function buttonOver()
    {
     var obj = window.event.srcElement;
     //obj.runtimeStyle.cssText = "background-color:#FFFFFF";
    // obj.className="Hover";
    alert("123231")
    alert(document.getElementsByName("year")[0].value)
    alert(document.getElementsByName("month")[0].value)
    alert(obj.innerText)
    var b=document.getElementsByName("year")[0].value+"-"+document.getElementsByName("month")[0].value+"-"+obj.innerText
    alert(b)
    window.open("a.html?a="+b,"","")
    //window.location="www.sina.com.cn";
    }
      

  2.   

    如果把这个做成小的页面,也就是别的页面上一点,这个东西就显示出来,这样的可以通过父子关系来付值function buttonOver()
    {
     var obj = window.event.srcElement;
     //obj.runtimeStyle.cssText = "background-color:#FFFFFF";
    // obj.className="Hover";
    alert("123231")
    alert(document.getElementsByName("year")[0].value)
    alert(document.getElementsByName("month")[0].value)
    alert(obj.innerText)
    var b=document.getElementsByName("year")[0].value+"-"+document.getElementsByName("month")[0].value+"-"+obj.innerText
    alert(b)
    opener.document.getElementById("time").value=b  //time可以是你打开这个页面上的
    //一个text
    self.close()
    //window.open("a.html?a="+b,"","")
    //window.location="www.sina.com.cn";
    }
      

  3.   

    看了半天,我觉得应该通过buttonOver()方法来传值,但是要传的日期我看了半天也没有找到。
      

  4.   

    真的有高人啊。
    <Script LANGUAGE="JavaScript">
     var months = new Array("一", "二", "三","四", "五", "六", "七", "八", "九","十", "十一", "十二");
     var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31);
     var days = new Array("SUN","MON", "TUE", "WED","THU", "FRI", "SAT");
     var classTemp;
     var today=new getToday();
     var year=today.year;
     var month=today.month;
     var newCal;  function getDays(month, year) {
      if (1 == month) return ((0 == year % 4) && (0 != (year % 100))) ||(0 == year % 400) ? 29 : 28;
      else return daysInMonth[month];
     } function getToday() {
      this.now = new Date();
      this.year = this.now.getFullYear();
      this.month = this.now.getMonth();
      this.day = this.now.getDate();
     } function Calendar() {
      newCal = new Date(year,month,1);
      today = new getToday();   
      var day = -1;
      var startDay = newCal.getDay();
      var endDay=getDays(newCal.getMonth(), newCal.getFullYear());
      var daily = 0;
      if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))
      {
       day = today.day;
      }
      var caltable = document.all.caltable.tBodies.calendar;
      var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());  for (var intWeek = 0; intWeek < caltable.rows.length;intWeek++)
       for (var intDay = 0;intDay < caltable.rows[intWeek].cells.length;intDay++)
       {
        var cell = caltable.rows[intWeek].cells[intDay];
        var montemp=(newCal.getMonth()+1)<10?("0"+(newCal.getMonth()+1)):(newCal.getMonth()+1);         
        if ((intDay == startDay) && (0 == daily)){ daily = 1;}
        var daytemp=daily<10?("0"+daily):(daily);
        var d="<"+newCal.getFullYear()+"-"+montemp+"-"+daytemp+">";
        if(day==daily) cell.className="DayNow";
        else if(intDay==6) cell.className = "DaySat";
        else if (intDay==0) cell.className ="DaySun";
        else cell.className="Day";
        if ((daily > 0) && (daily <= intDaysInMonth))
        {
         cell.innerText = daily;
         daily++;
        } else
        {
         cell.className="CalendarTD";
         cell.innerText = "";
        }
      }
      document.all.year.value=year;
      document.all.month.value=month+1;
     } function subMonth()
     {
      if ((month-1)<0)
      {
       month=11;
       year=year-1;
      } else
      {
       month=month-1;
      }
      Calendar();
     } function addMonth()
     {
      if((month+1)>11)
      {
       month=0;
       year=year+1;
      } else
      {
       month=month+1;
      }
      Calendar();
     } function setDate() 
     {
      if (document.all.month.value<1||document.all.month.value>12)
      {
       alert("Input error!");
       return;
      }
      year=Math.ceil(document.all.year.value);
      month=Math.ceil(document.all.month.value-1);
      Calendar();
     }
    </Script><Script>
    function buttonOver()
    {
     var obj = window.event.srcElement;
     //obj.runtimeStyle.cssText = "background-color:#FFFFFF";
    // obj.className="Hover";
    window.location="www.sinew.com.cn";
    }function buttonOut()
    {
     var obj = window.event.srcElement;
     window.setTimeout(function(){obj.runtimeStyle.cssText = "";},300);
    }
    </Script><Style>
    Input {font-family: verdana;font-size: 9pt;text-decoration: none;background-color: #FFFFFF;height: 20px;border: 1px solid #666666;color:#000000;}.Calendar {font-family: verdana;text-decoration: none;width: 170;background-color: #C0D0E8;font-size: 9pt;border:0px dotted #1C6FA5;}
    .CalendarTD {font-family: verdana;font-size: 7pt;color: #000000;background-color:#f6f6f6;height: 20px;width:11%;text-align: center;}.Title {font-family: verdana;font-size: 11pt;font-weight: normal;height: 24px;text-align: center;color: #333333;text-decoration: none;background-color: #A4B9D7;border-top-width: 1px;border-right-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-bottom-style:1px;border-top-color: #999999;border-right-color: #999999;border-bottom-color: #999999;border-left-color: #999999;}.Day {font-family: verdana;font-size: 7pt;color:#243F65;background-color: #E5E9F2;height: 20px;width:201%;text-align: center;}
    .DaySat {font-family: verdana;font-size: 7pt;color:#FF0000;text-decoration: none;background-color:#E5E9F2;text-align: center;height: 18px;width: 20%;}
    .DaySun {font-family: verdana;font-size: 7pt;color: #FF0000;text-decoration: none;background-color:#E5E9F2;text-align: center;height: 18px;width: 20%;}
    .DayNow {font-family: verdana;font-size: 7pt;font-weight: bold;color: #000000;background-color: #FFFFFF;height: 20px;text-align: center;}.DayTitle {font-family: verdana;font-size: 9pt;color: #000000;background-color: #C0D0E8;height: 20px;width:11%;text-align: center;}
    .DaySatTitle {font-family: verdana;font-size: 9pt;color:#FF0000;text-decoration: none;background-color:#C0D0E8;text-align: center;height: 20px;width: 20%;}
    .DaySunTitle {font-family: verdana;font-size: 9pt;color: #FF0000;text-decoration: none;background-color: #C0D0E8;text-align: center;height: 20px;width: 20%;}.DayButton {font-family: Webdings;font-size: 9pt;font-weight: bold;color: #243F65;cursor:hand;text-decoration: none;}</Style>
    <table border="0" cellpadding="0" cellspacing="1" class="Calendar" id="caltable">
    <thead>
         <tr align="center" valign="middle"> 
      <td colspan="7" class="Title">
       <a href="javaScript:subMonth();" title="up" Class="DayButton">3</a> <input name="year" type="text" size="4" maxlength="4" onkeydown="if (event.keyCode==13){setDate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"  onpaste="this.value=this.value.replace(/[^0-9]/g,'')"> -- <input name="month" type="text" size="1" maxlength="2" onkeydown="if (event.keyCode==13){setDate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"  onpaste="this.value=this.value.replace(/[^0-9]/g,'')">  <a href="JavaScript:addMonth();" title="down" Class="DayButton">4</a>
      </td>
     </tr>
     <tr align="center" valign="middle"> 
      <Script LANGUAGE="JavaScript">  
       document.write("<TD class=DaySunTitle id=diary >" + days[0] + "</TD>"); 
       for (var intLoop = 1; intLoop < days.length-1;intLoop++) 
        document.write("<TD class=DayTitle id=diary>" + days[intLoop] + "</TD>"); 
        document.write("<TD class=DaySatTitle id=diary>" + days[intLoop] + "</TD>"); 
      </Script>
     </TR> 
    </thead>
    <TBODY border=1 cellspacing="0" cellpadding="0" ID="calendar" ALIGN=CENTER ONCLICK="getDiary()">
     <Script LANGUAGE="JavaScript">
      for (var intWeeks = 0; intWeeks < 6; intWeeks++)
      {
       document.write("<TR style='cursor:hand'>");
       for (var intDays = 0; intDays < days.length;intDays++) 
       document.write("<TD class=CalendarTD onclick='buttonOver();' onMouseOut='buttonOut();'></TD>");
       document.write("</TR>");
      } 
     </Script>
    </TBODY>
    </TABLE>
    <Script  LANGUAGE="JavaScript">
     Calendar();
    </Script>
      

  5.   

    楼主
    不太明白你意思
    www.sinew.com.cn
    ----------->
    http://www.sinew.com.cn
      

  6.   

    十分感谢各位的帮助!特别是hbhbhbhbhb1021(天外水火(我要多努力)) 老大!真是高啊!
    再请教一下,马上接贴:
    cell.onclick=function(){document.location.href="http://www.csdn.net?selectedDate="+document.getElementById("year").value+document.getElementById("month").value+this.innerText}
    这句为什么这么写呢?不明白阿?
      

  7.   

    元素的单击事件链接才会有变化地
    document.getElementById("year").value      //取ID为year的值
    document.getElementById("month").value      //取ID为month的值
    this.innerText      //取文本内容的值三个值加起来组合
    就是按你说所地不同日期不同网页
      

  8.   

    flyskytoday(路漫漫夜漫漫) 已经回答了,cell.onclick=function(){//cell为日历有日期的单元格,点击之后执行如下方法
    document.location.href="http://www.csdn.net?selectedDate="+document.getElementById("year").value+document.getElementById("month").value+this.innerText}
    //document.location.href表示文档跳转到后面的url,
    //location.href=url也可以这样:location.assign(url)
    //document.getElementById("year").value      取ID为year的值,在IE中,
    //如果没有id=year的对象存在,则取name=year的对象
    //document.getElementById("month").value      取ID为month的值,同上。
    //this.innerText      取所点击对象的文本内容。在这里,this指向所点击的单元格。顺便说一下,
    var caltable = document.all.caltable.tBodies.calendar;
    document.all.year.value=year;
    document.all.month.value=month+1;
    这三句中, document.all不是标准的属性。请使用 W3C 的标准形式 document.getElementById() 。否则不兼容非IE浏览器。