注册 登录
编程论坛 ASP技术论坛

怎样才能给asp主页加上和系统挂钩的时钟?

hnegz 发布于 2007-10-19 04:40, 668 次点击
怎样才能给asp主页加上和系统挂钩的时钟?平时用的是静止的,我想改成走动的,怎么改?
3 回复
#2
永夜的极光2007-10-19 10:52
打开记事本,复制以下代码,然后保存为index.html,然后直接双击用浏览器打开,查看效果

<!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>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />
<title></title>
<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) ? \"下午 \" : \"上午 \" )
if(hours<=4){timeValue=\"凌晨\";}
if(hours>4&&hours<=11){timeValue=\"上午\";}
if(hours>11&&hours<=13){timeValue=\"中午\";}
if(hours>13&&hours<=18){timeValue=\"下午\";}
if(hours>18&&hours<=24){timeValue=\"晚上\";}
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>
</head>
<body topmargin=\"0\">
<table width=\"760\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
  <tr>
    <form name=clock>
    <td bgcolor=\"#eef0f8\" align=\"center\"><input name=thetime type=\"text\" style=\"font-size: 12pt;color:#000000;border:0;background-color: #eef0f8;\" size=\"12\" readonly=\"true\">
        </td>
</form>
    <script language=\"javascript\">
        startclock ();
    </script>
  </tr>
</table>
</body>
</html>

[此贴子已经被作者于2007-10-19 10:54:10编辑过]

#3
那边有朵蘑菇云2007-10-19 15:06
定了 VB里用TIMER控件可以实现
ASP我就不知道了 看这个帖子 才让我明白了 我靠 我脑袋上的疑云越来越重了
代码完全看不懂 我汗
#4
hnegz2007-10-20 12:18
谢谢,我试了能用,太谢谢
1