| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 781 人关注过本帖
标题:网页中显示当前时间
只看楼主 加入收藏
tml327
Rank: 1
等 级:新手上路
帖 子:510
专家分:0
注 册:2007-10-30
收藏
 问题点数:0 回复次数:0 
网页中显示当前时间
<html>
<head>
<title>当前时间</title>
</head>
<!--将以下代码加入HTML的<Body></Body>之间-->
<script language=JavaScript>
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;}
function startclock () {
stopclock();
showtime();}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )
timeValue += ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
document.clock.thetime.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;}
</SCRIPT>
<body onload=startclock()>
<form name=clock >
<input name=thetime style="font-size: 9pt;color:#000000;border:0px none; " size=12>
</form>
</body></html>
搜索更多相关主题的帖子: var 网页 showtime function Body 
2007-12-13 17:13
快速回复:网页中显示当前时间
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021830 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved