各位大哥,我在做一个考试系统,要定时交卷。谁能给个解决方案?(在线等待)

解决方案 »

  1.   

    qiezic(破晓),能具体说说怎么实现吗?
    谢谢
      

  2.   

    用JAVA的脚本可以实现,我公司做过
      

  3.   

    看看我公司做的
    <script language="JavaScript">
    var strExamLong =document.all["df"].value;
    function SetCookie(sName, sValue)
    {
      date = new Date();
      document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 2006 23:59:59 GMT;"
    }
    function GetCookie(sName)
    {
      var aCookie = document.cookie.split("; ");
      for (var i=0; i < aCookie.length; i++)
      {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0]) 
          return unescape(aCrumb[1]);
      }
      return 0;
    }
    function DelCookie(sName,sValue)
    {
      document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
    }totalTime = ((isNaN(parseInt(GetCookie('tm'))) || parseInt(GetCookie('tm')) ==0 )?(60 * 1000 *  strExamLong):parseInt(GetCookie('tm')))

    function aa(){

     DelCookie("tm",totalTime.toString());
     }
     
     
    var ms,ss,nl
    function CountTime()
    {    
        
    SetCookie("tm",totalTime.toString())
    totalTime = ((isNaN(parseInt(GetCookie('tm'))))?0:parseInt(GetCookie('tm')));
    totalTime -= 1000
    ms = Math.floor(totalTime/60/1000)
    ss = Math.floor((totalTime - ms * 60 * 1000)/1000)
    window.status = document.all.df.innerText = "【" + ms + "】分钟【" + ss + "】秒"
    window.setTimeout("CountTime()",1000)
    if(ms<0){
       DelCookie("tm")    
       //document.all.btnsubmit.style.display = 'block';
      // document.all.btnsubmit.click();
    //document.all('btnsubmit').click();
    //document.execCommand("btnsubmit");
      location.href="FirstIndex.aspx";
    }
    }
    CountTime()
    </script>
      

  4.   

    location.href="FirstIndex.aspx";
    谢谢!转到另一个界面怎么传值啊?
      

  5.   

    <SCRIPT  language="JavaScript">  
    <!--    
    function  display(){  
    rtime=etime-ctime;  
    if  (rtime>60)  
    m=parseInt(rtime/60);  
    else{  
    m=0;  
    }  
    s=parseInt(rtime-m*60);  
    if(s<10)  
    s="0"+s  
    window.status="时间还剩  :    "+m+":"+s  
    window.setTimeout("checktime()",1000)  
    }  
     
    function  settimes(){  
    var  shij=document.Form1.tb1.value;  
    alert("开始考试!")  
    var  time=  new  Date();  
    hours=  time.getHours();  
    mins=  time.getMinutes();  
    secs=  time.getSeconds();  
    etime=hours*3600+mins*60+secs;  
    etime+=shij*60;    //You  can  change  the  value  of  1200  according  to  how  much  time  you  wish  to  set  the  timer.  Where  1200  is  time  in  secs  (1200  =  20  mins  *  60  secs/min).  Max  time  is  60  mins  (3600secs)  
    checktime();  
    }  
     
    function  checktime(){  
    var  time=  new  Date();  
    hours=  time.getHours();  
    mins=  time.getMinutes();  
    secs=  time.getSeconds();  
    ctime=hours*3600+mins*60+secs  
    if(ctime>=etime){  
    expired();  
    }  
    else  
    display();  
    }  
     
    function  expired(){  
    alert("交卷时间已到了,系统将自动交卷");  
    //document.Form1.submit;  
    document.Form1.Button2.click;  
    //location.href="score.aspx";    //Put  here  the  next  page  
    }  
    document.oncontextmenu=settimes();  
    //  Done  hiding  -->  
       </SCRIPT>  
    document.Form1.Button2.click;为什么这句没有作用啊??????  
    要怎么样才可以?
      

  6.   

    试试这个方法Global.cs:
    protected void Application_Start(Object sender, EventArgs e)
    {
             System.Timers.Timer timer = new System.Timers.Timer (60000); 
             timer.Elapsed +=new System.Timers.ElapsedEventHandler(timer_Elapsed);
             timer.AutoReset = true;
             timer.Enabled = true;         Application.Lock(); 
             Application["TimeCounter"] = "1";
             Application.UnLock() ;
    }private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
    Application.Lock();
    int min = Convert.ToInt16 (Application["TimeStamp"]) +1;
    if(min == 60)
    {
    //时间到
    }
    Application["TimeStamp"] = min.ToString ();
    Application.UnLock() ;
    }