<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
function time(){
var t=new Date();//获取系统当前时间
var h=t.getHours();
var m=t.getMinutes();
var s=t.getSeconds();
var result=h+":"+m+":"+s;
//获取input框的对象
var txtTime = document.getElementById("dis");
//txtTime.value=result;
//给id是dis的input框设置value属性的值(result)
txtTime.setAttribute("value",result);
//setTimeOut,需要页面初始化时,加载函数time()
setTimeout("time()",1000);//必须在function里,而且只执行一次
}
//setInterval()每隔1秒钟调用一次函数time()
//setInterval("time()",1000);//function外,可以多次调用
</script>
<style>
.bg{
background-color:#FF7F50;
}
</style>
</HEAD>
<BODY οnlοad="time();">
<table>
<tr>
<td><img src="images2/mosou.jpg"/></td>
</tr>
<tr>
<td align="center">当前时间:<input type="text" id="dis" class="bg"/></td>
</tr>
</table>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
function time(){
var t=new Date();//获取系统当前时间
var h=t.getHours();
var m=t.getMinutes();
var s=t.getSeconds();
var result=h+":"+m+":"+s;
//获取input框的对象
var txtTime = document.getElementById("dis");
//txtTime.value=result;
//给id是dis的input框设置value属性的值(result)
txtTime.setAttribute("value",result);
//setTimeOut,需要页面初始化时,加载函数time()
setTimeout("time()",1000);//必须在function里,而且只执行一次
}
//setInterval()每隔1秒钟调用一次函数time()
//setInterval("time()",1000);//function外,可以多次调用
</script>
<style>
.bg{
background-color:#FF7F50;
}
</style>
</HEAD>
<BODY οnlοad="time();">
<table>
<tr>
<td><img src="images2/mosou.jpg"/></td>
</tr>
<tr>
<td align="center">当前时间:<input type="text" id="dis" class="bg"/></td>
</tr>
</table>
</BODY>
</HTML>