分时段显示不同的提示的网页JS特效代码

 1 脚本说明:
 2 把如下代码加入body区域中
 3 <SCRIPT>
 4 today=new Date();
 5 var day; var date; var hello; var wel;
 6 hour=new Date().getHours()
 7 if(hour < 6)hello='凌晨好'
 8 else if(hour < 9)hello='早上好'
 9 else if(hour < 12)hello='上午好'
10 else if(hour < 14)hello='中午好'
11 else if(hour < 17)hello='下午好'
12 else if(hour < 19)hello='傍晚好'
13 else if(hour < 22)hello='晚上好'
14 else {hello='夜里好!'}
15 if(today.getDay()==0)day='星期日'
16 else if(today.getDay()==1)day='星期一'
17 else if(today.getDay()==2)day='星期二'
18 else if(today.getDay()==3)day='星期三'
19 else if(today.getDay()==4)day='星期四'
20 else if(today.getDay()==5)day='星期五'
21 else if(today.getDay()==6)day='星期六'
22 date=(today.getYear())+''+(today.getMonth() + 1 )+''+today.getDate()+'';
23 if(hour<1)wel='子时';
24 else if(hour<3)wel='丑时';
25 else if(hour<5)wel='寅时';
26 else if(hour<7)wel='卯时';
27 else if(hour<9)wel='辰时';
28 else if(hour<11)wel='巳时';
29 else if(hour<13)wel='午时';
30 else if(hour<15)wel='未时';
31 else if(hour<17)wel='申时';
32 else if(hour<19)wel='酉时';
33 else if(hour<21)wel='戌时';
34 else if(hour<23)wel='亥时';
35 else {wel='子时';}
36 document.write(hello);
37 </SCRIPT>! 现在是<SCRIPT>
38 document.write(date + ' ' + day + ' ' + wel);
39     </SCRIPT> 

 

posted @ 2018-02-23 22:12  前端极客  阅读(721)  评论(0编辑  收藏  举报