我在前台中写了如下的倒计时代码,js调用后台的GetCourse()方法,可以调用,但是只是调用了一次,我想每隔6秒就去调用一次,每次启动都只调用一次,请高手帮吗呀
<SCRIPT language=javascript>temp=new Date();msPerDay=24*60*60*1000
a=1;
b=5;
c=5;
ff=0;
timeold=120*60*1000;
function show_student163_time(){
window.setTimeout("show_student163_time()", 1000);
if(ff==6)
{
"<%GetCourse();%>";
ff=0;
}
ff++; if(a<=0&&b<=0&&c<=0)
{
document.body.onbeforeunload="";
document.getElementById("Ibtn_submit").onclick="Ibtn_submit_Click1";
document.getElementById("Ibtn_submit").click();a=0;
b=0;
c=0;
return;}
else{if(b<=0&&c<=0){a--;}}if(b<=0&&c<=0){b=5;}
else{if(c<=0){b--;}}if(c<=0){c=5}
else{c--;}
span_dt_dt1.innerHTML="考试剩余:"+a+"小时"+b+"分"+(c)+"秒";
}
show_student163_time();
</SCRIPT>

解决方案 »

  1.   

    GetCourse是页面载入的时候执行一次,然后就不会调用了,动态调用后台的方法使用ajax
      

  2.   

    你还是用 ajax 将参数发送到 一个页面去执行相关方法 得到返回值。
      

  3.   

    调用一次页面就postback了
    js不行的.
      

  4.   

    那就定義個時間6秒執行一下,
     <script>
          
           function hello()
           {
             window.setTimeout('bind()',600000);--1分鍾
           }
           function bind()
           {            document.all.Button1.click(); --你調用的事件
           }     </script>