急:如何获得系统时间并通过判断显示“早上好”和“晚上好”? 根据获得的时间,通过switch语句给不同的时间段显示不同的内容即可:) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><BODY><script language="JavaScript"><!-- Hide this script from old browsers --function greeting(){var today = new Date();var hrs = today.getHours();document.writeln("<CENTER>");document.write("<H1>");if (hrs < 6)document.write("早晨");else if (hrs < 12)document.write("上午");else if (hrs <= 18)document.write("下午");elsedocument.write("晚上");document.writeln("好!</H1>");}greeting();// -- End Hiding Here --></script></BODY></html> 这个在explorer5。0里测试过了 也可以用hour(now())来取得小时,对其判断,然后分开问候。 <script language="javaScript"> <!-- now = new Date(),hour = now.getHours() if(hour < 6){document.write("凌晨好!")} else if (hour < 9){document.write("早上好!")} else if (hour < 12){document.write("上午好!")} else if (hour < 14){document.write("中午好!")} else if (hour < 17){document.write("下午好!")} else if (hour < 19){document.write("傍晚好!")} else if (hour < 22){document.write("晚上好!")} else {document.write("夜里好!")} // --> </script> 菜鸟请求帮助 谢谢大侠 文本编辑器 改变文字颜色的一个问题(ie) location.href()跟location.replace()什么区别? 这个日期格式怎么判断,要求输入这两种格式的日期。 获得打开父窗口的窗口 JS这样的写法有什么好处 框架分割线的移动 怎样往xml文件中指定的位置写一行? 网页打印,取部分打印的问题。 谁能告诉我这是怎么做,解决问题的给50分 各位,有没有学习JSP的好书,推着有分! 求正则表达式?在输入框中只能输入数字和负号!在线等!
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><BODY>
<script language="JavaScript">
<!-- Hide this script from old browsers --function greeting()
{
var today = new Date();
var hrs = today.getHours();
document.writeln("<CENTER>");
document.write("<H1>");
if (hrs < 6)
document.write("早晨");
else if (hrs < 12)
document.write("上午");
else if (hrs <= 18)
document.write("下午");
else
document.write("晚上");
document.writeln("好!</H1>");
}
greeting();// -- End Hiding Here -->
</script>
</BODY>
</html>
这个在explorer5。0里测试过了
<!--
now = new Date(),hour = now.getHours()
if(hour < 6){document.write("凌晨好!")}
else if (hour < 9){document.write("早上好!")}
else if (hour < 12){document.write("上午好!")}
else if (hour < 14){document.write("中午好!")}
else if (hour < 17){document.write("下午好!")}
else if (hour < 19){document.write("傍晚好!")}
else if (hour < 22){document.write("晚上好!")}
else {document.write("夜里好!")}
// -->
</script>