日期开窗2

Code
<html> 
<head> 
<title>Agenda</title> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<style type="text/css"> 
BODY { 
    FONT
-SIZE: 9pt; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; 

A { 
    FONT
-SIZE: 9pt; TEXT-DECORATION: none; color: #000000 

A:hover { 
    TEXT
-DECORATION: none; color: #000000 

A:link { 
    TEXT
-DECORATION: none 

A:visited { 
    TEXT
-DECORATION: none 

BR { 
    FONT
-SIZE: 9pt; height: 15pt; 

TD { 
    FONT
-SIZE: 9pt; LINE-HEIGHT: 11pt; 

input { 
    FONT
-SIZE: 9pt; height: 15pt; 

.SCROLLBAR { 
    SCROLLBAR
-FACE-COLOR: #718698
    SCROLLBAR
-HIGHLIGHT-COLOR: #899aa9; 
    SCROLLBAR
-SHADOW-COLOR: #506981
    SCROLLBAR
-3DLIGHT-COLOR: #5b7086; 
    SCROLLBAR
-ARROW-COLOR: #506981
    SCROLLBAR
-TRACK-COLOR: #5b7086; 
    SCROLLBAR
-DARKSHADOW-COLOR: #5b7086 

</style> 
<script language="JavaScript1.2"> 
<!-- 
 var 
Timer    = new Date(); 
 var years    
= Timer.getYear(); 
 var months    
= (Timer.getMonth()+1); 
 var days    
= Timer.getDate(); 
 var weeks    
= Timer.getDay(); 
 var Rec_List    
= ""
 Rec_List    
= ",20020202,20020608,20020815,20021219,20010125,20011105,2001706,20030715,20031203,20030416,"
  
 
function GetDays(the_year,the_month){ 
     var Max_day 
= 31
     
if (the_month==4 || the_month==6 || the_month==9 || the_month==11){ 
         Max_day 
= 30
     }
else if(the_month==2){ 
         
if(the_year%400==0){ 
            Max_day 
= 29
        }
else if(the_year%100==0){ 
            Max_day 
= 28
        }
else if(the_year%4==0){ 
            Max_day 
= 29
        }
else
            Max_day 
= 28
        } 
     } 
     return Max_day; 
 } 
  
 
function ShowPlan(the_year,the_month,the_day){ 
     var thisDate 
= the_year + "-" + (the_month+1+ "-" + the_day; 
     selDate.value
=thisDate; 
     selDate.innerText
=thisDate; 
    LayerDate.style.visibility
='hidden'; 
 } 
  
 
function HideDate(){ 
     
if(LayerDate.style.visibility!='hidden'){ 
        LayerDate.style.visibility='hidden'; 
    } 
 } 
  
 
function Calendar(the_year,the_month){ 
     var i 
= 0
     var FontColor; 
     var DateStr; 
     var New_Date 
= new Date(the_year,the_month,1
     var the_week 
= New_Date.getDay(); 
     var Max_day  
= GetDays(the_year,the_month+1
    var dummy 
= 7-(the_week+Max_day)%7
     var Cal_str  
= ""
     Cal_str 
+= "<table align=center width=100% border=0 cellpadding=1 cellspacing=1 bgcolor=#FF9900>"
    Cal_str 
+= "<tr bgcolor=#ffcc99>"
    Cal_str 
+= "<td width=14% align=center>星期日</td>"
    Cal_str 
+= "<td width=14% align=center>星期一</td>"
    Cal_str 
+= "<td width=14% align=center>星期二</td>"
    Cal_str 
+= "<td width=14% align=center>星期三</td>"
    Cal_str 
+= "<td width=14% align=center>星期四</td>"
    Cal_str 
+= "<td width=14% align=center>星期五</td>"
    Cal_str 
+= "<td width=14% align=center>星期六</td>"
    Cal_str 
+= "</tr><tr>\n"
    
for(i=0;i<the_week;i++){ 
        Cal_str 
+= "<td valign=top align=center bgcolor=#ffffff οnmοuseοut=this.bgColor='#ffffff' οnmοuseοver=this.bgColor='#f2f8ff'>&nbsp;</td>\n"
    } 
    
for(i=1;i<=Max_day;i++){ 
        FontColor 
= ((i+the_week)%7==1||(i+the_week)%7==0)?"red":"black" 
        DateStr 
= "," + the_year + (the_month<9?("0"+(parseInt(the_month)+1)):(parseInt(the_month)+1)) + (i<10?("0"+i):i) + ","
        Cal_str 
+= "<td valign=top align=center bgcolor=" + (Rec_List.search(DateStr)!=-1?"#FFCC33":"white"+ ((i==days&&the_year==years&&the_month==months-1)?" background=image/now.gif":""+ " οnmοuseοut=this.bgColor='" + (Rec_List.search(DateStr)!=-1?"#FFCC33":"#ffffff"+ "' οnmοuseοver=this.bgColor='#f2f8ff'>" 
        Cal_str 
+= "<a href=javascript:ShowPlan(" + the_year + "," + the_month + "," + i + ") style='color: " + FontColor + ";'>" + i + "</a></td>\n"
        
if((the_week+i)%7==0 && i!=Max_day) Cal_str += "</tr><tr>\n"
    } 
    
if(dummy < 7){ 
        
for(i=1;i<=dummy;i++){ 
            Cal_str 
+= "<td valign=top align=center bgcolor=#ffffff οnmοuseοut=this.bgColor='#ffffff' οnmοuseοver=this.bgColor='#f2f8ff'>&nbsp;</td>\n"
        } 
    } 
    Cal_str 
+= "</tr></table>"
    return(Cal_str); 
 } 
  
function DateChange(mode){ 
    var theYear
=parseInt(ShowYear.innerText); 
    var theMonth
=parseInt(ShowMon.innerText); 
    
if(mode){ 
        theMonth
++
        
if(theMonth>=13){ 
            theYear
++
            theMonth
=1
        } 
    }
else
        theMonth
--
        
if(theMonth<=0){ 
            theYear
--
            theMonth
=12
        } 
    } 
    ShowYear.innerText
=theYear; 
    ShowMon.innerText
=theMonth; 
    Cal_Tab.innerHTML
=Calendar(theYear,theMonth-1); 

function YearChange(){ 
    var theYear; 
    theYear
=prompt("Please input the year: (0 - 3000)",ShowYear.innerText); 
    
if(theYear==null || theYear=="") return false
    theYear
=parseInt(theYear); 
    theMon
=parseInt(ShowMon.innerText); 
    
if((theYear+"a")=="NaNa" || theYear>3000 || theYear<0){ 
        alert(
"输入错误!"); 
        return 
false
    }
else
        ShowYear.innerText
=theYear; 
        ShowMon.innerText
=theMon; 
        Cal_Tab.innerHTML
=Calendar(theYear,theMon-1); 
    } 
    setTimeout(
"LayerDate.style.visibility='visible'",10); 

function MonChange(){ 
    var theMon; 
    theMon
=prompt("Please input the Month: (1 - 12)",ShowMon.innerText); 
    
if(theMon==null || theMon=="") return false
    theMon
=parseInt(theMon); 
    theYear
=parseInt(ShowYear.innerText); 
    
if((theMon+"a")=="NaNa" || theMon>12 || theMon<1){ 
        alert(
"输入错误!"); 
        return 
false
    }
else
        ShowYear.innerText
=theYear; 
        ShowMon.innerText
=theMon; 
        Cal_Tab.innerHTML
=Calendar(theYear,theMon-1); 
    } 
    setTimeout(
"LayerDate.style.visibility='visible'",10); 

function showCalendar(){ 
    event.cancelBubble 
= true
    LayerDate.style.top 
= event.srcElement.offsetTop + event.srcElement.offsetHeight + 2
    LayerDate.style.left 
= event.srcElement.offsetLeft - 150
    
if(parseInt(LayerDate.style.left)<0) LayerDate.style.left = 0
    LayerDate.style.visibility 
= LayerDate.style.visibility=='hidden'?'visible':'hidden'; 
    return false

//--> 
</script> 
</head> 
<body onClick="HideDate()"> 
<p align=center>  
<p align=center> 
<input type=text id=selDate value="" style="width: 80px" readonly CLASS=NONULL><input type=button value="q" style="FONT-SIZE: 7pt; FONT-FAMILY: Wingdings 3; width: 15pt" onClick="showCalendar()"> 
 
<div id="LayerDate" onClick="event.cancelBubble=true" style="position:absolute; width:300px; height:115px; z-index:1; visibility: hidden; BORDER: 1 solid black;"> 
<table width="300" border="0" cellspacing="0" cellpadding="0" align="center"> 
  
<tr>  
    
<td width="40" align="center" bgcolor="#000000" nowrap> <input type="button" value="|" style="FONT-FAMILY: Wingdings 3;width: 20px" onClick="DateChange(false)"></td> 
    
<td width="100%" align="center" bgcolor="#000000" style="color: white;FONT-WEIGHT: bold; CURSOR: default" nowrap><span id="ShowYear" onClick="YearChange()"></span> 年 <span id="ShowMon" onClick="MonChange()"></span> 月</td> 
    
<td width="40" align="center" bgcolor="#000000" nowrap><input type="button" value="}" style="FONT-FAMILY: Wingdings 3;width: 20px" onClick="DateChange(true)"> </td> 
  
</tr> 
  
<tr>  
    
<td colspan="3" align="center"> <span id="Cal_Tab"></span> </td> 
  
</tr> 
  
<tr>  
    
<td height=30 colspan="3" valign="middle" style="cursor: default" onClick="Cal_Tab.innerHTML=Calendar(years,months-1);ShowYear.innerText=years;ShowMon.innerText=months"><image src=image/now.gif height=12>  
      
<b>今天:  
      
<script>document.write(years + "-" + months + "-" + days)</script> 
      
</b> </td> 
  
</tr> 
</table> 
</div> 
<script language="JavaScript1.2"> 
    ShowYear.innerText
=years; 
    ShowMon.innerText
=months; 
    Cal_Tab.innerHTML
=Calendar(years,months-1); 
    ShowPlan(years,(months
-1),days); 
</script> 
</body> 
</html> 

该文章转载自脚本之家:http:
//www.jb51.net/html/200708/48/10850.htm

转载于:https://www.cnblogs.com/safezone/articles/1263926.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值