在jsp页面中调用js的日历控件,如何 *** 作?

在jsp页面中调用js的日历控件,如何 *** 作?,第1张

好好看看下面的代码
<!--将以下代码加入HTML的<Body></Body>之间-->
<BODY>
<script language="JavaScript">
<!-- Hide this script from old browsers --
function greeting()
{
var today = new Date();
var hrs = todaygetHours();
documentwriteln("<CENTER>");
documentwrite("Good ");
if (hrs < 6)
documentwrite("(Early) Morning");
else if (hrs < 12)
documentwrite("Morning");
else if (hrs <= 18)
documentwrite("Afternoon");
else
documentwrite("Evening");
documentwrite("!");
documentwrite("当前时间是:");
dayStr = todaytoLocaleString();
documentwrite(dayStr);
documentwriteln("</CENTER>");
}
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 today = new Date();
var thisDay;
var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30,
31, 30, 31);
year = todaygetYear();
if (year<2000)
year=year+1900;
thisDay = todaygetDate();
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
monthDays[1] = 29;
nDays = monthDays[todaygetMonth()];
firstDay = today;
firstDaysetDate(1); // works fine for most systems
testMe = firstDaygetDate();
if (testMe == 2)
firstDaysetDate(0);
startDay = firstDaygetDay();
documentwriteln("<CENTER>");
documentwrite("<TABLE BORDER bgcolor=moccasin>");
documentwrite("<TR><TH COLSPAN=7>");
documentwrite(year+'年');
documentwrite(todaygetMonth()+1+'月');
documentwrite("<TR><TH>日<TH>一<TH>二<TH>三<TH>四<TH>五<TH>六");
documentwrite("<TR>");
column = 0;
for (i=0; i<startDay; i++)
{
documentwrite("<TD>");
column++;
}
for (i=1; i<=nDays; i++)
{
documentwrite("<TD>");
if (i == thisDay)
documentwrite("<FONT COLOR=\"red\">")
documentwrite(i);
if (i == thisDay)
documentwrite("</FONT>")
column++;
if (column == 7)
{
documentwrite("<TR>");
column = 0;
}
}
documentwrite("</TABLE>");
documentwriteln("</CENTER>");
}
greeting();
documentwrite("<br>");
calendar();
documentwrite("");
// -- End Hiding Here -->
</script>
</body>

<style>
time2{color:red;}
</style>
<body>
<table width="85" border="1">
<tr>
<td align='center' class='time1' id='time1' > </td>
</tr>
<tr>
<td height="47" align='center' class='time1' id='time2' style='font-size:200%'>aaa</td>
</tr>
<tr>
<td align='center' class='time1' id='time3'> </td>
</tr>
</table>
<script>
var d = new Date();
documentgetElementById('time1')innerHTML=dgetFullYear()+'年'+(dgetMonth()+1)+'月';
documentgetElementById('time2')innerHTML=dgetDate();
var c=dgetDay();
switch(c){
case 0:
a='星期日';
break;
case 1:
a='星期一';
break;
case 2:
a='星期二';
break;
case 3:
a='星期三';
case 4:
a='星期四';
case 5:
a='星期五';
case 6:
a='星期六';
}
documentgetElementById('time3')innerHTML=a;
if((c==6)||(c==0)){
documentgetElementById('time1')className='time2';
documentgetElementById('time2')className='time2';
documentgetElementById('time3')className='time2';
}else{
documentgetElementById('time1')className='time1';
documentgetElementById('time2')className='time1';
documentgetElementById('time3')className='time1';
}
</script>
</body>

demohtm // demo实例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 10 Transitional//EN" " >

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/10261772.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-06
下一篇 2023-05-06

发表评论

登录后才能评论

评论列表(0条)

保存