小墨の博客

梦想需要付诸行动,否则只能是梦

js根据不同时间显示不同问候语

用JS来实现网页上不同时间显示的问候语,不同时间打开网页,显示的问候语是不一样的。

点击代码右上角查看演示。

<!DOCTYPE html>
<html> 
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <script>
            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>
    </body>
</html>

参考:https://yaw.ee/127.html

张小弟之家

本文链接:
文章标题:

本站文章除注明转载/出处外,均为原创,若要转载请务必注明出处。转载后请将转载链接通过邮件告知我站,谢谢合作。本站邮箱:admin@only4.work

尊重他人劳动成果,共创和谐网络环境。点击版权声明查看本站相关条款。

    发表评论:

    搜索
    本文二维码
    标签列表
    站点信息
    • 文章总数:518
    • 页面总数:20
    • 分类总数:92
    • 标签总数:209
    • 评论总数:63
    • 浏览总数:244305

    | | |
    | |  Z-Blog PHP