功能正常,现在什么都没有
我完成了一个按钮点击功能,它会提醒时间和日期,它工作了.我保存了,关闭了记事本+,后来又回来了,现在当我什么都不点击时,底部没有错误代码,什么都没有,没有响应.
点击的按钮是
选择 | 换行 | 行号
- onclick="ShowDate()"
该函数为
选择 | 换行 | 行号
- function ShowDate() {
- var thetime = new Date();
- var weekday = thetime.getDay();
- var themonth = thetime.getMonth();
- var thedate = thetime.getDate();
- var theyear = thetime.getFullYear();
- var hour = thetime.getHours();
- var minutes = thetime.getMinutes();
- var seconds = thetime.getSeconds();
- var ap = (hour >= 12) ? 'p.m.' : 'a.m.';
- var someday = new Array(7);
- someday[0]="Sunday";
- someday[1]="Monday";
- someday[2]="Tuesday";
- someday[3]="Wednesday";
- someday[4]="Thursday";
- someday[5]="Friday";
- someday[6]="Saturday";
- var somemonth = new Array(12);
- somemonth[0]="January";
- somemonth[1]="February";
- somemonth[2]="March";
- somemonth[3]="April";
- somemonth[4]="May";
- somemonth[5]="June";
- somemonth[6]="July";
- somemonth[7]="August";
- somemonth[8]="September";
- somemonth[9]="October";
- somemonth[10]="November";
- somemonth[11]="December";
- if (hour < 1) {
- hour = 12;
- }
- if(minutes < 10){
- minutes = "0" + minutes;
- }
- if(seconds < 10){
- seconds = "0" + seconds;
- }
- if(hour > 5&&hour < 12) {
- window.alert('Good Morning! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
- }
- if(hour > 12&&hour < 19) {
- window.alert('Good afternoon! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
- }
- if(hour > 19&&hour < 5) {
- window.alert('Good Evening! Today is '+someday[weekday]+', '+somemonth[themonth]+' '+thedate+', '+theyear+'. The time is '+hour+':'+minutes+':'+seconds);
- }
- }
谢谢