利用JAVA SCRIPT自动显示时间 代码

来源:百度知道 编辑:UC知道 时间:2024/06/30 23:18:50
在上午之前显示GOOD MORNING!下午之前显示 GOOD AFTERNOON!其他时间显示GOOD EVENING!

<html>
<head>
<meta http-equiv=content-type content="text/html;charset=GBK">
<script language="javascript" type="text/javascript">
<!--
var date = new Date();
var curr;
function sayHello(){
this.msg = "";
curr = date.getHours();
if(curr <12){
this.msg = "GOOD MORNING";
}else if(curr > 12){
this.msg = "GOOD EVENING";
} else{
this.msg = "GOOD AFTERNOON";
}
document.getElementById("myTime").value = this.msg;
setTimeout("sayHello();", 1000);