学习首页 百科 人生课堂 办公软件 英语学习 操作系统 故事会 编程资料 软件学习 设计
铭瑶网 >> 学习首页 >> 编程 >> Form中的时钟
标题:Form中的时钟

【字体: 】 时间:2008-4-11 来源:互联网 作者:study

Form中的时钟

脚本说明:第一步:把如下代码加入<body>区域中<script language="JavaScript"><!--var timerID = nullvar timerRunning = falsefunction 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) ? hours - 12 : hours)    timeValue  += ((minutes < 10) ? ":0" : ":") + minutes    timeValue  += ((seconds < 10) ? ":0" : ":") + seconds    if (hours>=6 && hours<=12)       {timeValue  += ("上午")}    if(hours>12 && hours<=18)        {timeValue += ("下午")}    if(hours>18 && hours <=24)       {timeValue +=("晚上")}    if(hours<6)        {timeValue += ("深夜")}    document.clock.face.value = timeValue     timerID = setTimeout("showtime()",1000)    timerRunning = true}//--></script> <form method="POST" name="clock">                    <p>                       <input type="text" name="face" size="11" style="font-size: 9pt">                    </p>                  </form>第二步:把<body>区域改为<body bgcolor="#fef4d9" onLoad="startclock();">

查看/参与:讨论/评论 相关文章:Javascript