Loading... 用JS来实现网页上不同时间显示的问候语,不同时间打开网页,显示的问候语是不一样的。 ``` <script language="JavaScript"> document.write("<center><font color=#990099 size=-1> ") day = new Date() hr = day.getHours() minu=day.getMinutes() s="您好,现在是:"; s=s+hr+"点"+minu+"分。 "; if (hr ==1) document.write(s+"凌晨1点了!该休息了!") if (hr ==2) document.write(s+"工作狂,还在忙嘛?") if (hr ==3) document.write(s+"午夜3点!你决定不睡觉了嘛??") if (hr ==4) document.write(s+"凌晨4点了,您的工作精神一定要上报党中央!") if (hr ==5) document.write(s+"5点多了,您是刚起床还是还没睡啊?") if (hr ==6) document.write(s+"早上好!新一天又开始啦!有什么打算呢?") if (hr ==7) document.write(s+"吃早饭了嘛?") if ((hr ==8) || (hr == 9) || (hr ==10)) document.write(s+"祝您工作愉快!") if (hr ==11) document.write(s+"快中午啦,准备下班了嘛?") if (hr ==12) document.write(s+"中午好!你吃饭了嘛?") if ((hr==13) || (hr==14)) document.write(s+"准备准备要上班了!") if ((hr==15) || (hr==16) || (hr==17)) document.write(s+"下午好!") if ((hr==18) || (hr==19)) document.write(s+"该看新闻联播了!") if ((hr==20) || (hr==21) || (hr==22)) document.write(s+"休息下,找个电影看看睡觉吧?") if (hr==23) document.write(s+"不早了,快休息吧?") if (hr==0) document.write(s+"午夜时分,你可要注意身体呢!") document.write("</font></center>") </script> ``` 最后修改:2020 年 12 月 08 日 06 : 42 PM © 允许规范转载 赞赏 如果觉得我的文章对你有用,请随意赞赏 ×Close 赞赏作者 扫一扫支付 支付宝支付 微信支付