[JavaScript] 时间 →→→→→进入此内容的聊天室

来自 , 2021-03-20, 写在 JavaScript, 查看 110 次.
URL http://www.code666.cn/view/1517c866
  1. 1       <HTML>
  2. 2       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3. 3       <HEAD>
  4. 4       <TITLE>时间日期篇--当前时间</TITLE>
  5. 5       </HEAD>
  6. 6      
  7. 7       <BODY bgcolor="#fef4d2" onLoad=showTheCurrentTime() background="../images/background5.jpg">
  8. 8       <br>
  9. 9       <br>
  10. 10      <center>
  11. 11      <font color="ffaafa"><h2>时间日期篇--当前时间</h2></font>
  12. 12      <hr width=300>
  13. 13      <br><br>
  14. 14     
  15. 15      <!-- 案例代码1开始 -->
  16. 16     
  17. 17      <script LANGUAGE="JavaScript">
  18. 18     
  19. 19      function showMilitaryTime() {
  20. 20      if (document.form.showMilitary[0].checked) {
  21. 21      return true;
  22. 22      }
  23. 23      return false;
  24. 24      }
  25. 25      function showTheHours(theHour) {
  26. 26      if (showMilitaryTime() || (theHour > 0 && theHour < 13)) {
  27. 27      return (theHour);
  28. 28      }
  29. 29      if (theHour == 0) {
  30. 30      return (12);
  31. 31      }
  32. 32      return (theHour-12);
  33. 33      }
  34. 34      function showZeroFilled(inValue) {
  35. 35      if (inValue > 9) {
  36. 36      return "" + inValue;
  37. 37      }
  38. 38      return "0" + inValue;
  39. 39      }
  40. 40      function showAmPm() {
  41. 41      if (showMilitaryTime()) {
  42. 42      return ("");
  43. 43      }
  44. 44      if (now.getHours() < 12) {
  45. 45      return (" am");
  46. 46      }
  47. 47      return (" pm");
  48. 48      }
  49. 49      function showTheCurrentTime() {
  50. 50      now = new Date
  51. 51      document.form.showTime.value = showTheHours(now.getHours()) + ":" + showZeroFilled(now.getMinutes()) + ":" + showZeroFilled(now.getSeconds()) + showAmPm()
  52. 52      setTimeout("showTheCurrentTime()",1000)
  53. 53      }
  54. 54      </script>
  55. 55     
  56. 56     
  57. 57      <!-- 案例代码1结束 -->
  58. 58     
  59. 59     
  60. 60      <!-- 案例代码2开始 -->
  61. 61     
  62. 62      <form name="form">
  63. 63            <div align="center">
  64. 64         <center>
  65. 65              <p> <font color="#FFFFFF">
  66. 66                <!-- [Step1]: 这里可以改变显示列的长度 -->
  67. 67                <input type="text" name="showTime" size="11">
  68. 68                </font></p>
  69. 69            </center></div><div align="center"><center><p><input type="radio" name="showMilitary"
  70. 70            checked>
  71. 71                <font color="#FFFFFF">24 Hour Time<br>
  72. 72                <input type="radio" name="showMilitary">
  73. 73                12 Hour Time<br>
  74. 74                </font> </p>
  75. 75            </center></div>
  76. 76      </form>
  77. 77     
  78. 78      <!--案例代码2结束 -->
  79. 79     
  80. 80      </center></BODY>
  81. 81     
  82. 82      </HTML>
  83. 83     

回复 "时间"

这儿你可以回复上面这条便签

captcha