#2
cnfarer2011-11-24 14:27
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>javascript</title>
<script language="javascript">
function getCurrentTime(){
var date=new Date();
var year=date.getFullYear();
var month=date.getMonth() + 1;
var day=date.getDate();
var hour=date.getHours();
var seconds=date.getSeconds();
var minutes=date.getMinutes();
var timeString=date + '-' + month '-' + day + ':' + minutes ':' seconds;
return timeString;
}
getCurrentTime();
function refreshTime(){
document.getElementById('time').innerHTML = getCurrentTime(); //读取和设置HTML内容
}
window.onload=function(){
setInterval(refreshTime,1000);
}
</script>
</head>
<body>
<div id="time"></div>
</body>
</html>
以上是代码 , 但是时间显示不出来,我试试调用getCurrentTime()函数,但是提示 Js缺少 ,对象,请大家指教下,谢谢