我想实现当时间到时 自动执行提交试卷(也就是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>
<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>
<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>
//
// timers
//
this.timers.Enabled = true;
this.timers.Interval = 180000;
this.timers.Tick += new System.EventHandler(this.timers_Tick);时间到了 以后 触发 提交的方法