我想实现当时间到时 自动执行提交试卷(也就是button1的clic事件)<body bgcolor="#00cccc" onload="countTime()">     <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    
        <asp:Button ID="Button1" runat="server" Text="提交试卷" OnClick="Button1_Click" />
    </div>
    </form>
</body>
</html>
<script type ="text/javascript"> 
var timeLeft = 1 * 60 * 1000; 
function countTime() 

if(timeLeft == 0) 

alert("考试时间到!"); 
//在这里该如何写语句?return; 

var startMinutes = parseInt(timeLeft / (60 * 1000), 10); 
var startSec = parseInt((timeLeft - startMinutes * 60 * 1000)/1000) 
document.getElementById("Label1").innerText = "考试剩余时间:" + startMinutes + "分钟" + startSec + "秒"; 
timeLeft = timeLeft - 1000; 
setTimeout('countTime()',1000); 

</script> 

解决方案 »

  1.   

    document.getElementById('form1').submit()
      

  2.   

    参考下<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    <html xmlns="http://www.w3.org/1999/xhtml" >   
    <head>
        <title>jQuery Demo</title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
    <style> </style>
    <script type="text/javascript">
    window.onload = function(){
    setTimeout(function(){
    document.getElementsByTagName("input")[0].click();
    },5000);
    };
    </script>
    </head>
    <body>
    <input type="button" onclick="alert(1)" />
    </body>
    </html>
      

  3.   

    给timer 里面 写入 事件
    // 
                // timers
                // 
                this.timers.Enabled = true;
                this.timers.Interval = 180000;
                this.timers.Tick += new System.EventHandler(this.timers_Tick);时间到了 以后 触发 提交的方法