博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一个时钟显示的JavaScript文档
阅读量:6626 次
发布时间:2019-06-25

本文共 1750 字,大约阅读时间需要 5 分钟。

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <style type="text/css">
<style>
</style>
    <title>时钟</title>
    <script language="JavaScript">
        function showClock() {
        }
        function hideClock() {
        }
        var timerID = null
        var timerRunning = false
        function stopClock() {
            if (timerRunning)
                clearTimeout(timerID);
            timerRunning = false
            document.clock.face.value = "";
        }
        function showTime() {
            var now = new Date();
            var year = now.getYear();
            var month = now.getMonth() + 1;
            var date = now.getDate();
            var hours = now.getHours();
            var mins = now.getMinutes();
            var secs = now.getSeconds();
            var timeVal = "";
            timeVal += ((hours <= 12) ? hours : hours - 12);
            timeVal += ((mins < 10) ? ":0" : ":") + mins;
            timeVal += ((secs <= 10) ? ":0" : ":") + secs;
            timeVal += ((hours < 12) ? "AM" : "PM");
            timeVal += ((month < 10) ? " on 0" : " on ") + month + "-";
            timeVal += date + "-" + year;
            document.clock.face.value = timeVal;
            timerID = setTimeout("showTime()", 1000);
            timerRunning = true
        }
        function startClock() {
            stopClock();
            showTime();
        }
        function windowOpener(indexnum) {
            var loadpos = "date.html" + "#" + indexnum;
            controlWindow = window.open(loadpos, "date", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=620,height=400");
        }
    </script>
</head>
<body οnlοad="startClock()">
    <p align="center">
    </p>
    <div align="center">
        <center>
            <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="100%">
                        <form name="clock" οnsubmit="0">
                        <div align="center">
                            <center>
                                <p>
                                    <input type="text" name="face" size="20" value style="background-color: rgb(192,192,192)">
                                </p>
                            </center>
                        </div>
                        </form>
                    </td>
                </tr>
            </table>
        </center>
    </div>
</body>
</html>

 

显示的效果是:(此为静态效果)

转载于:https://www.cnblogs.com/dc-learn/archive/2013/01/22/2871242.html

你可能感兴趣的文章
怎么在win7让WAMP下的apache自动启动
查看>>
WIN2008R2下安装plsqldeveloper和toad
查看>>
jquery 通过点击事件获取id
查看>>
ELK学习笔记b
查看>>
Linux无人值守自动化安装详细配置流程!
查看>>
jquery实现radio按钮在分组状态下点击选中,再次点击取消选中
查看>>
【51CTO学院三周年】我和51CTO学院的点滴
查看>>
hadoop2.4.1+hbase0.98.3实现的分布式网盘系统初步
查看>>
ibatis批量新增-自增长序列
查看>>
linux系统管理之九:rpm安装包
查看>>
Linux系统中查看日志的常用命令
查看>>
java基础(二) 自增自减与贪心规则
查看>>
VMWare View的组件
查看>>
Oracle GoldenGate学习之--异构平台同步(Mysql到Oracle)
查看>>
Linux下date命令使用举例说明
查看>>
Centos6下SVN服务器(结合Apache)的搭建
查看>>
Reactor和Proactor模式
查看>>
实验:关于XPath中的13个轴
查看>>
品牌的网闸介绍
查看>>
手势滑动源码(适合新手)
查看>>