html日历显示不完整,求html代码,显示日历和时间的代码
var my = new Date();
//***************************************************函數(shù)開(kāi)始,這是用來(lái)顯示日歷的***********************
function showc() {
var k=1;
var j=1;
var today;
var tomonth;
var theday=1;//日期
var max;
var temp;
var tempday;//這個(gè)月第一天的星期
document.write ("" + my.getFullYear() + "-" + (my.getMonth()+1) + "");
document.write ("
document.write ("
");document.write ("
Sun");document.write ("
Mon");document.write ("
Tue");document.write ("
Wed");document.write ("
Thu");document.write ("
Fri");document.write ("
Sat");document.write ("
");temp=my.getDate();
my.setDate(1);
//document.write (my.getDate());
tempday=my.getDay();//返回第一天是星期幾
my.setDate(temp);
today=my.getDay();//返回現(xiàn)在星期幾
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;//這里沒(méi)有考慮閏月!!
//document.write (max);
}
for(k=0;k<6;k++) {
document.write ("
");for(j=0;j<=6;j++) {
document.write ("
");if(j>=(tempday)) {
tempday=0;//設(shè)置為最小,相當(dāng)于取消判斷條件
if(theday<=max) {
document.write ("");
if(theday==my.getDate())
document.write ("[" + theday + "]");
else if(j==0)
document.write ("" + theday + "");
else
document.write (theday + "");
theday++;
}
}
document.write ("
");}
document.write ("
");}
document.write ("
");}
//************************************************函數(shù)結(jié)束
showc();
這是顯示日歷代碼
溫馨提示:答案為網(wǎng)友推薦,僅供參考
總結(jié)
以上是生活随笔為你收集整理的html日历显示不完整,求html代码,显示日历和时间的代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 联想发布超时空智慧办公白皮书:超20%企
- 下一篇: 当阳一中2021高考成绩查询,宜昌202