码迷,mamicode.com
首页 > Web开发 > 详细

JS的Form文本框内的电子时钟

时间:2015-05-20 18:17:15      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>JS的Form文本框内的电子时钟丨石家庄玻璃隔断厂家</TITLE>
    </HEAD>
    <body bgcolor="#ffffff" onLoad="startclock();">
    <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) ? 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>
    </HTML>
    <br><br><hr>
    

 

JS的Form文本框内的电子时钟

标签:

原文地址:http://www.cnblogs.com/zhaozzm/p/4517634.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!