发新话题
打印

[软件技术] 生日提醒器

本主题由 第七把剑 于 2008-1-2 17:21 关闭 本主题被作者加入到个人文集中
把本帖网址贴到网络上任何地方,同样可以获得推广币和用户等级提升 详情点击这里
http://www.770921.com/viewthread.php? tid=5255&fromuid=0 复制本帖地址
8月活动:积分获大礼活动(实物奖励)
联盟论坛管理人员大招募!

生日提醒器

引用:
脚本说明:
第一步:把如下代码加入<head>区域中
<SCRIPT LANGUAGE="JavaScript">

<!--
function birthday(year,month,date,person) {
this.year=year
this.month=month
this.date=date
this.person=person
}

function birthdaylist() {
}

blist=new birthdaylist()
blist[0]= new birthday(84,1,16,"Matthew")
blist[1]= new birthday(53,1,27,"Brenda")
blist[2]= new birthday(82,3,1,"Ray")
blist[3]= new birthday(88,4,27,"Michael")
blist[4]= new birthday(86,9,2,"Andrew")
blist[5]= new birthday(49,11,24,"Raymond")

var now=new Date()
today=new Date(now.getYear(),now.getMonth(),now.getDate()) // today 0:00:00
function daysFromToday(sdate) {
return Math.round((sdate.getTime()-today.getTime())/(24*60*60*1000))
}

function writeNextBirthday(list) {
var daysToClosest=888
var closest
for (var i in list) {
thisDate=new Date(today.getYear(),list.month,list.date)
if (daysFromToday(thisDate)<0)
thisDate.setYear(today.getYear()+1)
if (daysFromToday(thisDate)<daysToClosest) {
daysToClosest=daysFromToday(thisDate)
closest=i
}
}
if (daysToClosest==0)
document.write("<B>So today "+list[closest].person+" became "+(today.getYear()-list[closest].year)+" years old !! Hoorah!</B><P>")
else if (daysToClosest==1)
document.write("So tomorrow "+list[closest].person+" will become "+(today.getYear()-list[closest].year)+" !<P>")
else
document.write("So the next birthday will be "+list[closest].person+"'s, in "+daysToClosest+" days.<P>")
}

// end hiding -->

</SCRIPT>

第二步:把如下代码加入区域中
<SCRIPT LANGUAGE="JavaScript">

<!--
writeNextBirthday(blist)
// -->

</SCRIPT>

TOP

呵呵,最好有个实例图片什么的更好!
既不回头,何必不忘?既已无缘,何须誓言?今日种种,似水无痕!明夕何夕,君已陌路!

TOP

发新话题