Beautiful JS calendar

Source: Internet
Author: User

<HTML> <Meta http-equiv = Content-Type content = "text/html; charset = gb2312">
<Script language = JavaScript type = text/JavaScript>
<! --
Function montharr (M0, M1, M2, M3, M4, M5, M6, M7, M8, M9, M10, m11 ){
This [0] = M0;
This [1] = m1;
This [2] = m2;
This [3] = m3;
This [4] = M4;
This [5] = M5;
This [6] = M6;
This [7] = M7;
This [8] = M8;
This [9] = M9;
This [10] = M10;
This [11] = M11;
}
Function calendar (){
VaR monthnames = "janfebmaraprmayjunjulaugsepoctnovdec ";
VaR today = new date ();
VaR ThisDay;
VaR monthdays = new montharr (31, 28, 31, 30, 31, 30, 31, 31, 30, 31 );

Year = today. Fig () + 1900;
ThisDay = today. getdate ();

If (Year % 4 = 0) & (Year % 100! = 0) | (Year % 400 = 0) monthdays [1] = 29;

Ndays = monthdays [today. getmonth ()];
Firstday = today;
Firstday. setdate (1); // works fine for most systems
Testme = firstday. getdate ();
If (testme = 2) firstday. setdate (0 );
Startday = firstday. getday ();

Document. write ('<Table border = "1" cellspacing = "0" cellpadding = "1" align = "center" bgcolor = "red"> <tr> <TD> <Table border = "0" cellspacing = "1" cellpadding = "1" bgcolor = "# ffeeee"> ');

Document. Write ('<tr> <TH colspan = "7" bgcolor = "# ffffcc"> ');
VaR daynames = new array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ");
VaR monthnames = new array ", "August September", "August October", "August November", "August December ");
VaR now = new date ();
Document. write ("<font style = font-size: 9pt; color: #990000>" + "ad" + now. getyear () + "year" + monthnames [now. getmonth ()] + "" + now. getdate () + "day" + daynames [now. getday ()] + "</font> ");
Document. writeln ('</Th> </tr> <TH bgcolor = "red"> <font style = "font-size: 9pt; color: white "> day </font> </Th> ');
Document. writeln ('<TH bgcolor = "# ff6699"> <font style = "font-size: 9pt; color: White"> 1 </font> </Th> ');
Document. writeln ('<TH bgcolor = "# ff6699"> <font style = "font-size: 9pt; color: White"> 2 </font> </Th> ');
Document. writeln ('<TH bgcolor = "# ff6699"> <font style = "font-size: 9pt; color: White"> 3 </font> </Th> ');
Document. writeln ('<TH bgcolor = "# ff6699"> <font style = "font-size: 9pt; color: White"> 4 </font> </Th> ');
Document. writeln ('<TH bgcolor = "# ff6699"> <font style = "font-size: 9pt; color: White"> 5 </font> </Th> ');
Document. writeln ('<TH bgcolor = "# ff6699"> <font style = "font-size: 9pt; color: White"> 6 </font> </Th> ');
Document. writeln ("</tr> <tr> ");
Column = 0;
For (I = 0; I <startday; I ++ ){
Document. writeln ("/n <TD> <font style = font-size: 9pt> </font> </TD> ");
Column ++;
}

For (I = 1; I <= ndays; I ++ ){
If (I = ThisDay ){
Document. writeln ('</TD> <TD align = "center" bgcolor = "# ffefef"> <font style = font-size: 9pt; color: red> <B> ')
}
Else {
Document. writeln ('</TD> <TD bgcolor = "# ffffff" align = "center"> <font style = font-size: 9pt; font-family: Arial; font-weight: bold; color: #660033> ');
}
Document. writeln (I );
If (I = ThisDay) document. writeln ("</font> </TD> ")
Column ++;
If (column = 7 ){
Document. writeln ("<tr> ");
Column = 0;
}
}
Document. writeln ('<tr> <TD colspan = "7" align = "center" valign = "TOP" bgcolor = "# dd3333"> <form name = "Clock" onsubmit =" 0 "> <font style = font-size: 9pt; color: # ffffff> current time <input type = "text" name = "face" size = "12" align = "TOP"> </font> </TD> </tr> </table> </TD> </tr> </table> </form> ');
}
// -->
</SCRIPT>

<Script language = JavaScript>
VaR timerid = NULL;
VaR timerrunning = false;
Function stopclock (){
If (timerrunning)
Cleartimeout (timerid );
Timerrunning = false ;}

Function Showtime (){
VaR now = new date ();
VaR hours = now. gethours ();
VaR minutes = now. getminutes ();
VaR seconds = now. getseconds ()
VaR timevalue = "" + (hours> 12 )? Hours-12: Hours)
Timevalue + = (minutes <10 )? ": 0": ":") + minutes
Timevalue + = (seconds <10 )? ": 0": ":") + seconds
Timevalue + = (hours> = 12 )? "PM": "am"
Document. Clock. Face. value = timevalue;
Timerid = setTimeout ("Showtime ()", 1000 );
Timerrunning = true ;}
Function startclock (){
Stopclock ();
Showtime ();}
</SCRIPT>

<Meta content = "mshtml 6.00.2900.3020" name = generator> <Body onload = "startclock (); timerone = Window. setTimeout">
<Script language = JavaScript type = text/JavaScript>

<! --
Calendar ();
// -->
</SCRIPT>
</Body>  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.