- 積分
- 54
- 威望
- 54
- 金錢
- 26
- 最後登錄
- 2012-8-30
|
如圖:
這個月曆的代碼出現後 都會再右邊
如何把他移動到中間
--------------------------------------------
代碼:- <style>
- .shd {style;border:1px dashed; border-color:blue;
- color:white ;font:9pt Verdana;
- background-color:black}
- .shd2 { color:red ;font:9pt Verdana; }
- .shd3 { colorrange ;font:9pt Verdana; }
- .shd4 { color:green ;font:9pt Verdana; }
- </style>
- <script language="JavaScript">
- function greeting(){
- var today = new Date();
- var hrs = today.getHours();
- document.writeln("<TABLE width=220 cellSpacing=2 cellPadding=2 class=shd>");
- document.write("<tr><td COLSPAN=7 align=center class=shd>");
- if (hrs < 6)
- document.write("(Early) Morning");
- else if (hrs < 12)
- document.write("早安!");
- else if (hrs <= 18)
- document.write("午安!");
- else
- document.write("晚安!");
- document.writeln("<tr><td COLSPAN=7 align=center class=shd>");
- dayStr = today.toLocaleString();
- document.write(dayStr);
- document.writeln("");}
- 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, 30, 31);
- year = today.getYear();
- 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);
- testMe = firstDay.getDate();
- if (testMe == 2)
- firstDay.setDate(0);
- startDay = firstDay.getDay();
- document.write("<TR><TD class=shd><FONT class=shd3>日<TD class=shd>一<TD class=shd>二<TD class=shd>三<TD class=shd>四<TD class=shd>五<TD class=shd><FONT class=shd4>六");
- document.write("<TR>");
- column = 0;
- for (i=0; i<startDay; i++){
- document.write("<TD>");
- column++;}
- for (i=1; i<=nDays; i++){
- document.write("<TD class=shd>");
- if (i == thisDay)
- document.write("<FONT class=shd2>")
- document.write(i);
- if (i == thisDay)
- document.write("")
- column++;
- if (column == 7){
- document.write("<TR>");
- column = 0;}}
- document.write("</TABLE>");
- document.writeln("");}
- greeting();
- document.write("");
- calendar();
- document.write("");
- </script>
複製代碼 |
|