WEB开发网
开发学院网页设计JavaScript JavaScript:变色日历 阅读

JavaScript:变色日历

 2010-09-14 13:26:43 来源:WEB开发网   
核心提示:<script language="JScript"><!-- Begin//place these scripts within BODY tag if you are using IE 4.0 or below.//// Release date: 2000.5.9// Any

<script language="JScript">
<!-- Begin //place these scripts within BODY tag if you are using IE 4.0 or below.
//****************************************************************************
// Release date: 2000.5.9
// Anyone may modify it to satify his needs, but please leave this comment ahead.
//****************************************************************************
var gdCtrl = new Object();
var gcGray = "#808080";
var gcToggle = "#ffff00";
var gcBG = "#cccccc";
var gdCurDate = new Date();
var giYear = gdCurDate.getFullYear();
var giMonth = gdCurDate.getMonth()+1;
var giDay = gdCurDate.getDate();
var VicPopCal = new Object();
//****************************************************************************
// Param: popCtrl is the widget beyond which you want this calendar to appear;
//    dateCtrl is the widget into which you want to put the selected date;
//    popCal is the widget to display the calendar; 
// i.e.: <input type="text" name="dc" style="text-align:center" readonly><INPUT type="button" value="V" onclick="fPopCalendar(dc,dc,popCal);return false">
//****************************************************************************
function fPopCalendar(popCtrl, dateCtrl, popCal){
 parent.event.cancelBubble=true;
 VicPopCal = popCal;
 gdCtrl = dateCtrl;
 fSetYearMon(giYear, giMonth);
 var point = fGetXY(popCtrl);
 with (VicPopCal.style) {
 left = point.x;
top = point.y+popCtrl.offsetHeight+1;
visibility = ’visible’;
 }
 xywf(VicPopCal) ;
 // in order to make compatible with IE4.x , here I cut two line below off.
 // VicPopCal.all("popFrame").width=document.all("popTable").offsetWidth;
 // VicPopCal.all("popFrame").height=document.all("popTable").offsetHeight;
 // if u only target on IE5.x, uncommented them and delete the width&height prop in <IFrame> tag
 // thus you will find the 3rd para in fDrawCal() now works perfectly.
}
function fSetDate(iYear, iMonth, iDay){
 gdCtrl.value = iMonth+"-"+iDay+"-"+iYear; //Here, you could modify the locale as you need !!!!
 VicPopCal.style.visibility = "hidden";
}
function fSetSelected(aCell){
 var iOffset = 0;
 var iYear = parseInt(tbSelYear.value);
 var iMonth = parseInt(tbSelMonth.value);
 aCell.bgColor = gcBG;
 with (aCell.children["cellText"]){
 var iDay = parseInt(innerText);
 if (color==gcGray)
 iOffset = (Victor<10)?-1:1;
iMonth += iOffset;
if (iMonth<1) {
 iYear--;
 iMonth = 12;
}else if (iMonth>12){
 iYear++;
 iMonth = 1;
}
 }
 fSetDate(iYear, iMonth, iDay);
}
function Point(iX, iY){
this.x = iX;
this.y = iY;
}
function fBuildCal(iYear, iMonth) {
 var aMonth=new Array();
 for(i=1;i<7;i++)
 aMonth[i]=new Array(i);
 var dCalDate=new Date(iYear, iMonth-1, 1);
 var iDayOfFirst=dCalDate.getDay();
 var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();
 var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;
 var iDate = 1;
 var iNext = 1;
 for (d = 0; d < 7; d++)
aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++;
 for (w = 2; w < 7; w++)
 for (d = 0; d < 7; d++)
 aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++);
 return aMonth;
}
function fDrawCal(iYear, iMonth, iCellWidth, iDateTextSize) {
 var WeekDay = new Array("Su","Mo","Tu","We","Th","Fr","Sa");
 var styleTD = " bgcolor=’"+gcBG+"’ width=’"+iCellWidth+"’ bordercolor=’"+gcBG+"’ valign=’middle’ align=’center’ style=’font:bold "+iDateTextSize+" Courier;";      //Coded by Liming Weng(Victor Won) email:victorwon@netease.com
 with (document) {
write("<tr>");
for(i=0; i<7; i++)
 write("<td "+styleTD+"color:#990099’ >" + WeekDay[i] + "</td>");
write("</tr>");
 for (w = 1; w < 7; w++) {
 write("<tr>");
 for (d = 0; d < 7; d++) {
 write("<td id=calCell "+styleTD+"cursor:hand;’ onMouseOver=’this.bgColor=gcToggle’ onMouseOut=’this.bgColor=gcBG’ onclick=’fSetSelected(this)’>");
 write("<font id=cellText Victor=’Liming Weng’> </font>");
 write("</td>")
 }
 write("</tr>");
}
 }
}
function fUpdateCal(iYear, iMonth) {
 myMonth = fBuildCal(iYear, iMonth);
 var i = 0;
 for (w = 0; w < 6; w++)
for (d = 0; d < 7; d++)
 with (cellText[(7*w)+d]) {
 Victor = i++;
 if (myMonth[w+1][d]<0) {
  color = gcGray;
  innerText = -myMonth[w+1][d];
 }else{
  color = ((d==0)||(d==6))?"red":"black";
  innerText = myMonth[w+1][d];
 }
 }
}
function fSetYearMon(iYear, iMon){
 tbSelMonth.options[iMon-1].selected = true;
 for (i = 0; i < tbSelYear.length; i++)
if (tbSelYear.options[i].value == iYear)
 tbSelYear.options[i].selected = true;
 fUpdateCal(iYear, iMon);
}
function fPrevMonth(){
 var iMon = tbSelMonth.value;
 var iYear = tbSelYear.value;
 if (--iMon<1) {
  iMon = 12;
  iYear--;
 }
 fSetYearMon(iYear, iMon);
}
function fNextMonth(){
 var iMon = tbSelMonth.value;
 var iYear = tbSelYear.value;
 if (++iMon>12) {
  iMon = 1;
  iYear++;
 }
 fSetYearMon(iYear, iMon);
}
function fGetXY(aTag){
 var oTmp = aTag;
 var pt = new Point(0,0);
 do {
 pt.x += oTmp.offsetLeft;
 pt.y += oTmp.offsetTop;
 oTmp = oTmp.offsetParent;
 } while(oTmp.tagName!="BODY");
 return pt;
}
var gMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
with (document) {
write("<table id=’popTable’ border=’0’ bgcolor=’#6699cc’>");
write("<TR>");
write("<td valign=’middle’ align=’center’><input type=’button’ name=’PrevMonth’ value=’<’ style=’height:20;width:20;FONT:16 Fixedsys’ onClick=’fPrevMonth()’>");
write(" <select name=’tbSelMonth’ onChange=’fUpdateCal(tbSelYear.value, tbSelMonth.value)’ Victor=’Won’>");
for (i=0; i<12; i++)
write("<option value=’"+(i+1)+"’>"+gMonths[i]+"</option>");
write("</SELECT>");
write(" <SELECT name=’tbSelYear’ onChange=’fUpdateCal(tbSelYear.value, tbSelMonth.value)’ Victor=’Won’>");
for(i=1990;i<2015;i++)
write("<OPTION value=’"+i+"’>"+i+"</OPTION>");
write("</SELECT>");
write(" <input type=’button’ name=’PrevMonth’ value=’>’ style=’height:20;width:20;FONT:16 Fixedsys’ onclick=’fNextMonth()’>");
write("</td>");
write("</TR><TR>");
write("<td align=’center’>");
write("<DIV style=’background-color:teal;’><table width=’100%’ border=’0’ cellpadding=’2’>");
fDrawCal(giYear, giMonth, 19, 12);
write("</table>");
write("</td>");
write("</TR><TR><TD align=’center’>");
write("<font style=’cursor:hand;font:12 Fixedsys’ onclick=’fSetDate(giYear,giMonth,giDay)’ onMouseOver=’this.style.color=gcToggle’ onMouseOut=’this.style.color=0’>Today: "+gMonths[giMonth-1]+" "+giDay+", "+giYear+"</font>");
write("</TD></TR>");write("</TD></TR>");
write("</TABLE>");
}
// End -- Coded by Liming Weng, email: victorwon@netease.com -->
</script>
</li>
<li style="margin-top:20px; line-height:18px; text-align:left; padding-left:10px;margin-left:0px;"><br />
<p>以上内容由 <a href="http://www.sudu.cn">华夏名网</a> 搜集整理,如转载请注明原文出处,并保留这一部分内容。</p>
<table width="98%" border="1" cellpadding="4" cellspacing="0" bordercolor="#333333" style="border-collapse:collapse">
 <tr>
  <td bgcolor="#eeeeee">  “华夏名网” http://www.sudu.cn 和 http://www.bigwww.com 是成都飞数科技有限公司的网络服务品牌,专业经营虚拟主机,域名注册,VPS,服务器租用业务。公司创建于2002年,经过6年的高速发展,“华夏名网”已经成为我国一家知名的互联网服务提供商,被国外权威机构webhosting.info评价为25大IDC服务商之一。</td>
 </tr>
</table>
<p>华夏名网网址导航: <a href="http://www.sudu.cn/webhosting">虚拟主机</a> <a href="http://www.sudu.cn/webhosting">双线主机</a> <a href="http://www.sudu.cn/webhosting">主机</a> <a href="http://www.sudu.cn/domain">域名注册</a> <a href="http://www.sudu.cn/domain">cn域名</a> <a href="http://www.sudu.cn/domain">域名</a> <a href="http://www.sudu.cn/server">服务器租用</a> <a href="http://www.sudu.cn/server">酷睿服务器</a> <a href="http://www.sudu.cn/vps">vps</a> <a href="http://www.sudu.cn/vps">vps主机</a></p></li>
<li style="text-align:left; margin-top:15px; padding-left:10px; margin-left:0px;">
(阅读次数:171)</li>
<li style="margin-top:10px;margin-left:0px;">上一篇:
<a href="/info/html/edu/20071121/7249.html">内核空间SMP编程</a>  下一篇:
<a href="/info/html/edu/20071121/7251.html">RSA加密实例分析</a>
</li>
<li style="border:#CCCCCC solid 1px; height:28px!important;height:30px; margin-top:10px; padding-top:10px;margin-left:0px;">[<img src=http://tech.ddvip.com/2008-11/"/info/article/img/file_move.gif" width="17" height="18" align="absmiddle"><A href="http://j5c.ddvip.com/index.php#" onClick="window.external.AddFavorite('http://www.idcnews.net','');">收藏</A>] [<img src=http://tech.ddvip.com/2008-11/"/info/article/img/menuarrow.gif" width="16" height="15" align="absmiddle">推荐] [<img src=http://tech.ddvip.com/2008-11/"/info/article/img/menumember.gif" width="16" height="15" align="absmiddle"><a href="/info/article/feedBack.php/aId_7250.html">评论</a>] [<a href="http://j5c.ddvip.com/index.php#" onClick="window.print()">打印本页</a>] [<a href="http://j5c.ddvip.com/index.php#" onClick="history.go(-1)">返回上一页</a>][<a onClick="window.close()" href="http://j5c.ddvip.com/index.php#">关闭窗口</a>] </li>
<form action="/info/article/articleInfo.php?action=addInfoReview" method="post" name='form2' id='form2'>
<li style="margin-top:10px; text-align:left;margin-left:10px;">昵称:
 <label>
 <input name="tineName" type="text" id="tineName" value="游客" size="20">
 </label>
 (为空则显示guest) </li>
 <li style="margin-top:10px; text-align:left;margin-left:10px;">评论分数:
  <input type="radio" name="score" value="1">
  <span class="STYLE1">★</span>
  <input type="radio" name="score" value="2">
  <span class="STYLE1">★
  ★</span>
  <input name="score" type="radio" value="3" checked>
  <span class="STYLE1">★★★</span>
  <input type="radio" name="score" value="4">
  <span class="STYLE1">★★★★</span>
  <input type="radio" name="score" value="5">
  <span class="STYLE1">★★★★★</span>
  <input name="aId" type="hidden" id="aId" value="7250">
 </li>
 <li style="margin-top:10px; text-align:left; margin-left:10px;">评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。</li>
<li style="margin-top:10px; text-align:left;margin-left:10px;">
 <label>
 <textarea name="reviewContent" cols="70" rows="6" id="reviewContent" class="revContet">

Tags:JavaScript 变色 日历

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接