thehour = thedate.gethours();
-------->
thehour = thedate.getHours();
注意大小写

解决方案 »

  1.   

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <script language="JavaScript">
    function hello()
    {
    var thedate;
    var thehour;
    thedate = new Date();
    thehour = thedate.getHours();//getHours();中的h大写
    if (thehour>=0 &&thehour<=5)
    {
    document.write("朋友现在是凌晨了,要注意身体啊!");
    }
    if (thehour>=5 &&thehour<=11)
    {document.write("朋友上午好!");
    }
    if (thehour>=11 &&thehour<=14)
    {document.write("朋友中午好!");
    }
    if (thehour>=14 &&thehour<=18)
    {
    document.write("朋友下午好!");
    }
    if (thehour>=18 &&thehour<=24)
    {document.write("朋友晚上早点休息!");
    }
    }
    </script>
    <script language="JavaScript">
     hello();
    </script>
    </body>
    </html>