当前位置: 代码迷 >> JavaScript >> 做日历解决办法
  详细解决方案

做日历解决办法

热度:108   发布时间:2012-03-09 21:42:55.0
做日历
如何利用javascript在网页中做一个日历

------解决方案--------------------
不是几行代码可以完成的,网上有很多做的不错的,可以搜索一下
------解决方案--------------------
<SCRIPT>
today=new Date();
var day; var date; var hello; var wel;
hour=new Date().getHours()
if(hour < 6)hello= '凌晨好 '
else if(hour < 9)hello= '早上好 '
else if(hour < 12)hello= '上午好 '
else if(hour < 14)hello= '中午好 '
else if(hour < 17)hello= '下午好 '
else if(hour < 19)hello= '傍晚好 '
else if(hour < 22)hello= '晚上好 '
else {hello= '夜里好! '}
if(today.getDay()==0)day= '星期日 '
else if(today.getDay()==1)day= '星期一 '
else if(today.getDay()==2)day= '星期二 '
else if(today.getDay()==3)day= '星期三 '
else if(today.getDay()==4)day= '星期四 '
else if(today.getDay()==5)day= '星期五 '
else if(today.getDay()==6)day= '星期六 '
date=(today.getYear())+ '年 '+(today.getMonth() + 1 )+ '月 '+today.getDate()+ '日 ';
if(hour <1)wel= '子时 ';
else if(hour <3)wel= '丑时 ';
else if(hour <5)wel= '寅时 ';
else if(hour <7)wel= '卯时 ';
else if(hour <9)wel= '辰时 ';
else if(hour <11)wel= '巳时 ';
else if(hour <13)wel= '午时 ';
else if(hour <15)wel= '未时 ';
else if(hour <17)wel= '申时 ';
else if(hour <19)wel= '酉时 ';
else if(hour <21)wel= '戌时 ';
else if(hour <23)wel= '亥时 ';
else {wel= '子时 ';}
///document.write(hello);
</SCRIPT>
<font color= "#FFFFFF "> 今天是 :
<SCRIPT>
///document.write(date + ' ' + day + ' ' + wel);
document.write(date + ' ' + day );
</SCRIPT>
------解决方案--------------------
网上有很多,你要是要的话,给个邮箱我给你发过去。
------解决方案--------------------
<html>

<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 网页特效|Linkweb.cn/Js|---一个很漂亮实用的日历 </title>
<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, 30, 31);
year = today.getYear() +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);
testMe = firstDay.getDate();
if (testMe == 2) firstDay.setDate(0);
startDay = firstDay.getDay();
document.write( " <div id= 'rili ' style= 'position:absolute;width:140px;left:300px;top:100px; '> ")
document.write( " <TABLE width= '217 ' BORDER= '0 ' CELLSPACING= '0 ' CELLPADDING= '2 ' BGCOLOR= '#0080FF '> ")
document.write( " <TR> <TD> <table border= '0 ' cellspacing= '1 ' cellpadding= '2 ' bgcolor= 'Silver '> ");
  相关解决方案