<script>
<!--
var tSeconds=0;
var tMinutes=0;
var tHours=0;
var timer=null;
function schedule(hours,minutes,seconds){
tHours = hours;
tMinutes = minutes;
tSeconds = seconds;
//TODO check..
run();
}
function run(){
var date=new Date();
if((date.getMinutes()-tMinutes==0)
&&(date.getSeconds()-tSeconds==0)
&&(date.getHours()-tHours==0)){
toDo();
window.clearTimeout(timer);
}else{
timer = window.setTimeout("run()",1);
}
}
function toDo(){
//Add your operation here
alert('do some thing');
}
-->
</script>
<body onload="schedule(20,15,00)">
备注:
1、shedule(20,15,00)之间的数字代表小时,分钟,秒
2、function toDo(){
//Add your operation here
alert('do some thing');
}
这函数里面即为你要运行的函数。如果想运行后台函数:
1)先在前台建立个按钮<asp:Button ID="Button1" runat="server" Text="获取数据" onclick="Button1_Click" />;
2)在后台Button1_Click里编写你所需运行的功能;
3)在前台JS里toDo()函数中调用按钮函数:
function toDo(){
//Add your operation here
document.getElementById("Button1").click();
}
以上方法均测试过,未发现问题。