定时闹钟
各位高手帮帮小弟,我要做个定时闹钟,就是定一个时间,在到时间的时候就单出一个框提醒用户。有示例的发个示例,谢谢啊。急用!~~~~~
[解决办法]
JS实现的我用的个DatePicker日期控件选时间。
不用也行自己做时间格式验证
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <script src="js/DatePicker/WdatePicker.js" language="javascript"></script> <script type="text/javascript"> function getNowTime(){ var dsq = null; var now= new Date(); var year=now.getYear(); var month=now.getMonth()+1; if(month<10){ month = "0"+month; } var day=now.getDate(); if(day<10){ day = "0"+day; } var hour=now.getHours(); if(hour<10){ hour = "0"+hour; } var minute=now.getMinutes(); if(minute<10){ minute = "0"+minute; } var second=now.getSeconds(); if(second<10){ second = "0"+second; } var nowdate=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; var txtime = document.getElementById("now").value; if(nowdate == txtime){ alert("闹铃:"+nowdate); clearTimeout(dsq); } dsq = setTimeout("getNowTime()",1000); } </script> </head> <body> 请选择提醒时间:<input type="text" name="now" size="20" style="margin-right:5px;" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" > <input type="button" onclick="getNowTime()" value="定时"/> </body></html>