分时问候代码

时间:2026-02-14 14:37:09

1、<script>

today=new Date();

var day; var date; var hello; var wel;

hour=new Date().getHours()

if(hour < 6)hello='凌晨好'

else if(hour < 9)hello='早上好'

else if(hour < 12)hello='上午好'

else if(hour < 14)hello='中午好'

else if(hour < 17)hello='下午好'

else if(hour < 19)hello='傍晚好'

else if(hour < 22)hello='晚上好'

else {hello='夜里好'}

if(today.getDay()==0)day='星期日'

else if(today.getDay()==1)day='星期一'

else if(today.getDay()==2)day='星期二'

else if(today.getDay()==3)day='星期三'

else if(today.getDay()==4)day='星期四'

else if(today.getDay()==5)day='星期五'

else if(today.getDay()==6)day='星期六'

date=(today.getYear())+'年'+(today.getMonth() + 1 )+'月'+today.getDate()+'日';

document.write(hello);

    </script>

<script>

document.write(date + ' ' + day + ' ' );

      </script>

2、修改分时问候文本的颜色为白色

显示网页中脚本元素步骤:

“编辑”菜单栏→首选参数→不可见元素→选择“脚本”,如下图所示:

方法一:拖动鼠标选中脚本标记,在属性面板下字体颜色设置为白色

方法二:应用<font></font>标记来修改字体颜色。

分时问候代码

© 2026 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com