zoukankan      html  css  js  c++  java
  • js 钟表

     1 <script>
     2 document.write('<TR><td colspan="3" align="right" bgcolor="#C6C3C6" valign="bottom">');
     3 document.write('<font class="whiteword"><b>现在时间</b></font></td><td valign="bottom" colspan="4" bgcolor="#C6C3C6">');
     4 document.write('<div id="clock" class="clock"></div>');
     5 document.write('</TD>');
     6 </script>
     7 
     8 <script LANGUAGE="JavaScript">
     9 
    10 var timerID = null;
    11 var timerRunning = false;
    12 function stopclock (){
    13 
    14 if(timerRunning)
    15 clearTimeout(timerID);
    16 timerRunning = false;
    17 
    18 
    19 }
    20 
    21 function showtime () {
    22 var now = new Date();
    23 var hours = now.getHours();
    24 var minutes = now.getMinutes();
    25 var seconds = now.getSeconds();
    26 var timeValue = " " + ((hours <10) ? "0" :"")+hours;
    27 timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
    28 timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
    29 document.getElementById("clock").innerHTML=timeValue;
    30 timerID = setTimeout("showtime()",1000);
    31 timerRunning = true;
    32 }
    33 function startclock () {
    34 stopclock();
    35 showtime();
    36 }
    37 
    38 </script>
    39 <script language="javascript">
    40 
    41 startclock();
    42 </script>
    白发三千丈
  • 相关阅读:
    localStorage用法
    es6写法
    div滚动条
    搜索框聚焦和失焦
    初步理解前端模块化开发
    clam安装
    div行高不确定,文字和图片居中
    html页面设置<span>的高度和宽度
    一款好用的wangEditor编辑器
    3月23 防360网页的示意图
  • 原文地址:https://www.cnblogs.com/sanpoye/p/2541283.html
Copyright © 2011-2022 走看看