一个兼容IE、Firefox和Opera浏览器的英文日历脚…
2008-02-23 07:50:03来源:互联网 阅读 ()
}
function decYear()
{
for (i=0; i<6; i )
{
newYear = (i nStartingYear)-1
if (newYear==yearSelected)
{
txtYear = " <B>" newYear "</B> "
}
else
{
txtYear = " " newYear " "
}
document.getElementById("y" i).innerHTML = txtYear
}
nStartingYear --;
bShow=true
}
function selectYear(nYear)
{
yearSelected=parseInt(nYear nStartingYear);
yearConstructed=false;
constructCalendar();
popDownYear();
}
function constructYear()
{
popDownMonth()
sHTML = ""
if (!yearConstructed)
{
sHTML = "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='clearInterval(intervalID1);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\"decYear()\",30)' onmouseup='clearInterval(intervalID1)'>-</td></tr>"
j = 0
nStartingYear = yearSelected-3
for (i=(yearSelected-3); i<(yearSelected 3); i )
{
sName = i;
if (i==yearSelected)
{
sName = "<B>" sName "</B>"
}
sHTML = "<tr><td id='y" j "' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='this.style.backgroundColor=\"\"' style='cursor:pointer' onclick='selectYear(" j ");event.cancelBubble=true'> " sName " </td></tr>"
j ;
}
sHTML = "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='clearInterval(intervalID2);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\"incYear()\",30)' onmouseup='clearInterval(intervalID2)'> </td></tr>"
document.getElementById("selectYear").innerHTML = "<table width=44 style='font-family:arial; font-size:11px; border-width:1; border-style:solid; border-color:#a0a0a0;' bgcolor='#FFFFDD' onmouseover='clearTimeout(timeoutID2)' onmouseout='clearTimeout(timeoutID2);timeoutID2=setTimeout(\"popDownYear()\",100)' cellspacing=0>" sHTML "</table>"
yearConstructed = true
}
}
function popDownYear()
{
clearInterval(intervalID1)
clearTimeout(timeoutID1)
clearInterval(intervalID2)
clearTimeout(timeoutID2)
crossYearObj.visibility= "hidden"
}
function popUpYear()
{
var leftOffset
constructYear()
crossYearObj.visibility = (dom||ie)? "visible" : "show"
leftOffset = parseInt(crossobj.left) document.getElementById("spanYear").offsetLeft
if (ie)
{
leftOffset = 6
}
crossYearObj.left = leftOffset
crossYearObj.top = parseInt(crossobj.top) 26
}
/*** calendar ***/
function WeekNbr(n)
{
// Algorithm used:
// From Klaus Tondering's Calendar document (The Authority/Guru)
// hhtp://www.tondering.dk/claus/calendar.html
// a = (14-month) / 12
// y = year 4800 - a
// m = month 12a - 3
// J = day (153m 2) / 5 365y y / 4 - y / 100 y / 400 - 32045
// d4 = (J 31741 - (J mod 7)) mod 146097 mod 36524 mod 1461
// L = d4 / 1460
// d1 = ((d4 - L) mod 365) L
// WeekNumber = d1 / 7 1
year = n.getFullYear();
month = n.getMonth() 1;
if (startAt == 0)
{
day = n.getDate() 1;
}
else
{
day = n.getDate();
}
a = Math.floor((14-month) / 12);
y = year 4800 - a;
m = month 12 * a - 3;
b = Math.floor(y/4) - Math.floor(y/100) Math.floor(y/400);
J = day Math.floor((153 * m 2) / 5) 365 * y b - 32045;
d4 = (((J 31741 - (J % 7)) % 146097) % 36524) % 1461;
L = Math.floor(d4 / 1460);
d1 = ((d4 - L) % 365) L;
week = Math.floor(d1/7) 1;
return week;
}
function constructCalendar ()
{
var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31)
var dateMessage
var startDate = new Date (yearSelected,monthSelected,1)
var endDate
if (monthSelected==1)
{
endDate = new Date (yearSelected,monthSelected 1,1);
endDate = new Date (endDate - (24*60*60*1000));
numDaysInMonth = endDate.getDate()
}
else
{
numDaysInMonth = aNumDays[monthSelected];
}
datePointer = 0
dayPointer = startDate.getDay() - startAt
if (dayPointer<0)
{
dayPointer = 6
}
sHTML = "<table border=0 style='font-family:verdana;font-size:10px;'><tr>"
if (showWeekNumber==1)
{
sHTML = "<td width=27><b>" weekString "</b></td><td width=1 rowspan=7 bgcolor='#d0d0d0' style='padding:0px'><img src='" imgDir "divider.gif' width=1></td>"
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
