<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script>
//定义时钟显示的函数
function displayTime() {

var today = new Date();
// 定义日期对象
var years = today.getFullYear();
var mouths = today.getMonth();
var days = today.getDay();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
// 从日期对象中中获得时间信息


minutes = fixTime(minutes);
seconds = fixTime(seconds);
// 引入fixTime()函数,使分和秒可以正常显示,对于小于10的数字则在该数字前加一个0

var the_time = years +"年" + mouths +"月"+ days+"日"+ " "+hours + ":" + minutes + ":" + seconds;
//将时间字符串组合在一起并写出
window.document.the_form.the_text.value = the_time;
//把表格的值重新写一遍,相当于刷新时间

the_timeout= setTimeout('displayTime();',500);
//每半秒钟执行一次该函数,即500毫秒
}
function fixTime(the_time)
{if (the_time <10) { the_time = "0" + the_time; } return the_time; }
</script>

</head>
<body onload=displayTime()>
<form name="the_form">
    <font face="宋体" color ="red"><input type="text" name="the_text" size="30" readonly ="readonly"></font>
    <%--<font><input type ="text" name ="the_text" /></font>--%>
</form>
</body>
</html>

posted on 2006-12-02 10:57  ipusr  阅读(192)  评论(0)    收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示