功能正常,现在什么都没有

我完成了一个按钮点击功能,它会提醒时间和日期,它工作了.我保存了,关闭了记事本+,后来又回来了,现在当我什么都不点击时,底部没有错误代码,什么都没有,没有响应.
点击的按钮是

选择 | 换行 | 行号
  1. onclick="ShowDate()"

该函数为

选择 | 换行 | 行号
  1. function ShowDate() {
  2.  var thetime = new Date();
  3.  var weekday = thetime.getDay();
  4.  var themonth = thetime.getMonth();
  5.  var thedate = thetime.getDate();
  6.  var theyear = thetime.getFullYear();
  7.  var hour = thetime.getHours();
  8.  var minutes = thetime.getMinutes();
  9.  var seconds = thetime.getSeconds();
  10.  var ap = (hour >= 12) ? 'p.m.' : 'a.m.';
  11.  var someday = new Array(7);
  12.  someday[0]="Sunday";
  13.  someday[1]="Monday";
  14.  someday[2]="Tuesday";
  15.  someday[3]="Wednesday";
  16.  someday[4]="Thursday";
  17.  someday[5]="Friday";
  18.  someday[6]="Saturday";
  19.  var somemonth = new Array(12);
  20.  somemonth[0]="January";
  21.  somemonth[1]="February";
  22.  somemonth[2]="March";
  23.  somemonth[3]="April";
  24.  somemonth[4]="May";
  25.  somemonth[5]="June";
  26.  somemonth[6]="July";
  27.  somemonth[7]="August";
  28.  somemonth[8]="September";
  29.  somemonth[9]="October";
  30.  somemonth[10]="November";
  31.  somemonth[11]="December";
  32.  
  33.  if (hour < 1) {
  34.    hour = 12;
  35.    }
  36.  if(minutes < 10){
  37.    minutes = "0" + minutes;
  38.    }
  39.  if(seconds < 10){
  40.    seconds = "0" + seconds;
  41.    } 
  42.  if(hour > 5&&hour < 12) {
  43.    window.alert('Good Morning! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
  44.    }
  45.  if(hour > 12&&hour < 19) {
  46.    window.alert('Good afternoon! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
  47.    } 
  48.  if(hour > 19&&hour < 5) {
  49.    window.alert('Good Evening! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
  50.    }
  51.  }
  52.  

谢谢

# 回答1


您的代码只在6-11和13-18点起作用.

标签: Javascript

添加新评论