爱者家园主页制作 → 网页特效代码:页面显示时间日期
查看完整版本:网页特效代码:页面显示时间日期
2007/8/7 19:41:33

将下面的代码放到<body></body>之间合适的位置,在页面显示时间日期


<script language="JavaScript">
wenzi10_n=new Date(),wenzi10_h=wenzi10_n.getHours()
if(wenzi10_h<6){document.write("该休息了,这么早就起床吗?")}
else if(wenzi10_h<8){document.write("早上好!")}
else if(wenzi10_h<12){document.write("上午好!")}
else if(wenzi10_h<14){document.write("中午好!")}
else if(wenzi10_h<18){document.write("下午好!")}
else if(wenzi10_h<22){document.write("晚上好!")}
else if(wenzi10_h<24){document.write("夜深了!该休息了,要注意身体!")}
</script>
<!--日期-->
<script language="JavaScript">
<!--
calendar=new Date();
day=calendar.getDay();
month=calendar.getMonth();
date=calendar.getDate();
year=calendar.getYear();
if (year< 100) year=1900+year;
cent=parseInt(year/100);
g=year % 19;
k=parseInt((cent-17)/25);
i=(cent-parseInt(cent/4)-parseInt((cent-k)/3)+19*g+15) % 30;
i=i-parseInt(i/28)*(1-parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j=(year+parseInt(year/4)+i+2-cent+parseInt(cent/4)) % 7;
l=i-j;
emonth=3+parseInt((l+40)/44);
edate=l+28-31*parseInt((emonth/4));
emonth--;
var dayname=new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
var monthname =
new Array ("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月" );
document.write("<font color=000080>"+year +"年");
document.write(monthname[month]);
document.write(date+"日"+" ");
document.write(dayname[day]+" "+"</font>");
if ((month==0)&&(date==1)) document.write("&nbsp&nbsp<font size=2 color=FF0000>今天是<元旦></font>&nbsp&nbsp");
if ((month==2)&&(date==8)) document.write("&nbsp&nbsp<font size=2 color=FF0000>今天是<三八妇女节></font>&nbsp&nbsp");
if ((month==4)&&(date==1)) document.write("&nbsp&nbsp<font size=2 color=FF0000>今天是<国际劳动节></font>&nbsp&nbsp");
if ((month==4)&&(date==4)) document.write("&nbsp&nbsp<font size=2 color=FF0000>今天是<青年节></font>&nbsp&nbsp");
if ((month==5)&&(date==1)) document.write("&nbsp&nbsp<font size=2 color=FF0000>今天是<国际儿童节></font>&nbsp&nbsp");
if ((month==6)&&(date==1)) document.write("&nbsp&nbsp<font size=2 color=FF0000>今天是<党的生日></font>&nbsp&nbsp");
if ((month==7)&&(date==1)) document.write("&nbsp&nbsp<font size=2 color=FF0000>今天是<建军节></font>&nbsp&nbsp");
if ((month==11)&&(date==25)) document.write("&nbsp&nbsp<font size=2 color=FF0000>今天是<圣诞节></font>&nbsp&nbsp");
document.write("</font>");
document.write("<span id='clock'></span>");
var now,hours,minutes,seconds,timeValue;
function showtime(){
now=new Date();
hours=now.getHours();
minutes=now.getMinutes();
seconds=now.getSeconds();
timeValue="<font size=2>";
timeValue+=(hours >= 12) ? " 下午 " : " 上午 ";
timeValue+=((hours > 12) ? hours-12 : hours)+" 点 ";
timeValue+=((minutes <10)?"0":"")+minutes+" 分 ";
timeValue+=((seconds <10)?"0":"")+seconds+" 秒 ";
timeValue+="</font>";
clock.innerHTML=timeValue;
setTimeout("showtime()",100);
}
showtime();
//-->
</script>

Powered by BBSXP 2008 SP2 ACCESS © 1998-2024
Processed in 0.01 second(s)