javascript html實現網頁版日曆代碼,javascript日曆

來源:互聯網
上載者:User

javascript html實現網頁版日曆代碼,javascript日曆

本文執行個體為大家分享了網頁版日曆代碼,供大家參考,具體內容如下

實現代碼:

<html> <head>  <link rel="stylesheet" type="text/css" href="Skin.css">  <style>  <!--  table{ text-align: center }  -->  </style> </head>  <body>  <div align="center">   <script language="javascript">   var my = new Date();      function showc() {    var k=1;    var j=1;    var today;    var tomonth;    var theday=1;//日期    var max;    var temp;    var tempday;//這個月第一天的星期    document.write ("<b>" + my.getFullYear() + "-" + (my.getMonth()+1) + "</b>");    document.write ("<table border='1' width='273' height='158'>");    document.write ("<tr>");    document.write ("<td height='23' width='39'><font color='red'>Sun</font></td>");    document.write ("<td height='23' width='39'>Mon</td>");    document.write ("<td height='23' width='39'>Tue</td>");    document.write ("<td height='23' width='39'>Wed</td>");    document.write ("<td height='23' width='39'>Thu</td>");    document.write ("<td height='23' width='39'>Fri</td>");    document.write ("<td height='23' width='39'>Sat</td>");    document.write ("</tr>");    temp=my.getDate();    my.setDate(1);    //document.write (my.getDate());    tempday=my.getDay();//返回第一天是星期幾    my.setDate(temp);    today=my.getDay();//返回現在星期幾       switch ((my.getMonth()+1)) {    case 1:    case 3:    case 5:    case 7:    case 8:    case 10:    case 12:    max=31;    break;    case 4:    case 6:    case 9:    case 11:    max=30;    break;    default:    max=29;//這裡沒有考慮閏月!!    //document.write (max);    }    for(k=0;k<6;k++) {    document.write ("<tr>");    for(j=0;j<=6;j++) {    document.write ("<td height='23' width='39'>");    if(j>=(tempday)) {    tempday=0;//設定為最小,相當於取消判斷條件    if(theday<=max) {     document.write ("<a title=" + my.getFullYear() + "-" + (my.getMonth()+1) + "-" +theday + " target='_blank' href=detail.asp?date=" + theday + ">");     if(theday==my.getDate())     document.write ("<font color='green'>[" + theday + "]</font></a>");     else if(j==0)     document.write ("<font color='red'>" + theday + "</font></a>");     else     document.write (theday + "</a>");     theday++;    }    }    document.write ("</td>");    }    document.write ("</tr>");    }    document.write ("</table>");   }      showc();  </script>  </div> <body></html>

以上就是本文的全部內容,希望大家可以輕鬆實現網頁版日曆。

您可能感興趣的文章:
  • javascript實現的簡易的DatePicker日曆
  • js日曆功能對象
  • javascript實現日曆控制項(年月日關閉按鈕)
  • 修改js Calendar日曆控制項 相容IE9/Google/Firefox
  • 很好用的js日曆演算法詳細代碼
  • 簡約JS日曆控制項 執行個體代碼
  • 純js簡單日曆實現代碼
  • js實現日曆可獲得指定日期周數及星期幾樣本分享(js擷取星期幾)
  • 輕量級的原生js日曆外掛程式calendar.js使用指南

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.