时间不能跟着走
不知道那里出问题。找了好久也没发现问题。那位大侠帮忙看下。感激不尽。<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function printdate(){
var now=new Date();
var year=now.getYear();
var month=now.getMonth();
var date=now.getDate();
var day=now.getDay();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
var str="早上好";
if(hour>=0&&hour<12)
{
str="早上好";
}
if(hour>=12&&hour<=18)
{
str="下午好";
}
if(hour>18)
{
str="晚上好";
}
var week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.write("今天是"+year+"年"+month+"月"+date+"日"+hour+"时"+minute+"分"+second+"秒\t"+week[day]+"\t\t"+str);
var mytime=setTimeout("printdate()",1000);
}
</script>
</head><body onload="printdate()">
</body>
</html>
不知道那里出问题。找了好久也没发现问题。那位大侠帮忙看下。感激不尽。<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function printdate(){
var now=new Date();
var year=now.getYear();
var month=now.getMonth();
var date=now.getDate();
var day=now.getDay();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
var str="早上好";
if(hour>=0&&hour<12)
{
str="早上好";
}
if(hour>=12&&hour<=18)
{
str="下午好";
}
if(hour>18)
{
str="晚上好";
}
var week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.write("今天是"+year+"年"+month+"月"+date+"日"+hour+"时"+minute+"分"+second+"秒\t"+week[day]+"\t\t"+str);
var mytime=setTimeout("printdate()",1000);
}
</script>
</head><body onload="printdate()">
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
<script type="text/javascript">
function printdate(){
var now=new Date();
var year=now.getYear();
var month=now.getMonth();
var date=now.getDate();
var day=now.getDay();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
var str="早上好";
if(hour>=0&&hour <12)
{
str="早上好";
}
if(hour>=12&&hour <=18)
{
str="下午好";
}
if(hour>18)
{
str="晚上好";
}
var week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.body.innerHTML="今天是"+year+"年"+month+"月"+date+"日"+hour+"时"+minute+"分"+second+"秒\t"+week[day]+"\t\t"+str;
var mytime=setTimeout("printdate()",1000);
}
</script>
</head> <body onload="printdate()">
</body>
</html>
onload后的document.write会把当前文档清掉