请高人指点

解决方案 »

  1.   

    document.getElementById("objiD").innerHTML+="要输出的内容";
      

  2.   

    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <script language="javascript">
       
       
    function dates()
    {      var days=new Date(years,Months,0).getDate();
          var dates=new Date(years,Months-1,1).getDay();
       
        document.write("<table border=1 bgcolor=#E2CCEA frame=void rules=none>");
         document.write("<tr>");
        document.write("<td>");
        document.write("<a id=R>");
        document.write("f</a>");
        document.write("</td>");
        document.write("<td colspan=5 align=center>");
        document.write(years+'年'+Months+'月'+day+'日');
        document.write("</td>");
        document.write("<td   >");
        document.write("<a onclick=javascript:E(this); id=L >");
         
        document.write("f</a>");
        document.write("</td>");
        document.write("</tr>");
        document.write("<tr>");
        document.write("<td style=color:#EE79A0;>星期日<br>sun"); 
        document.write("<br>");
        document.write("</td>");
        document.write("<td>星期一<br>Mon");
        document.write("<br>");
        document.write("</td>");
        document.write("<td>星期二<br>Tue");
        document.write("<br>");
        document.write("</td>");
        document.write("<td>星期三<br>Wed");
        document.write("<br>");
        document.write("</td>");
        document.write("<td>星期四<br>Thu");
        document.write("<br>");
        document.write("</td>");
        document.write("<td>星期五<br>Fri");
        document.write("<br>");
        document.write("</td>");
        document.write("<td style=color:#EE79A0;>星期六<br>Sat");
        document.write("<br>");
        document.write("</td>");
      
        h=1;
        for(i=0;i<=5;i++)
        {  document.write("<tr>");
           if(i==0)
          { for(x=1;x<=dates;x++)
            { document.write("<td>");
               document.write();
               document.write("</td>");
             }
            for(y=1;y<=7-dates;y++)
            {
              document.write("<td>");             
            if(h==day  ) 
            { document.write("<font color=#D8617B >");
              document.write(h);
              document.write("</font>");}
              else
              {document.write(h);
                   }
               document.write("</td>");
               h++;
            }
            }     
            else{
             for(j=0;j<=6;j++)
            {  if(h<=days)
              { document.write("<td>");
               if(h==day) 
                 { document.write("<font color=#D8617B >");
                   document.write(h);
                   document.write("</font>");}
                    else
                    {document.write(h);
                   }
                    document.write("</td>");}
             h++;}
             
               }
       
      document.write("</tr>");
    }
    document.write("</table>");}
    function R()

      Months=Months-1;
    }
     function L()
    {  if(Months<12)
       { Months=Months+1;
          
        dates();
     }
      
    }
    function right()
    {  
       if(Months>1)
       {
          dates();
         }
     } function E(x)
    {   var idL=document.getElementById("L");;
       var idR=document.getElementById("R");
        if(x==idL)
      L();
      
    }
     var year=new Date();
       var day=year.getDate();
       var years=year.getYear();
       var Months=year.getMonth()+1;
       var years;
       var Months;
    </script>
    <style>
        #R{}
        #L{}
    </style>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body><script language="javascript">
     
    dates();
    document.write("fff");
    </script>
        
       
        
        </body>
    </html>
    以上是我正在寫的一個日歷的代碼,(我只寫了一個左邊功能),但只能實現1月到2月,就不能實現月份相加的效果,在網上找答案懷疑是ducument.write 的輸出問題,但還是不知道怎么寫下去!請高人指點!!