我在asp.net中創建了一個使用javascript的倒計時器。完成時間後,Button1
變爲禁用狀態,但當我重新加載頁面時,倒數計時器將被重置並啓用Button1
。如何永久禁用在asp.net中使用Javascript的按鈕?
當timer等於零時,我想永久禁用Button1
。我的代碼是:
var tim;
var min = 01;
var sec = 00;
var f = new Date();
function f1() {
f2();
}
function f2() {
if (parseInt(sec) > 0) {
sec = parseInt(sec) - 1;
document.getElementById("showtime").innerHTML = ""+min+" Minutes ,"+sec+" Seconds";
tim = setTimeout("f2()", 1000);
}
else {
if (parseInt(sec) == 0) {
min = parseInt(min) - 1;
if (parseInt(min) == -1) {
clearTimeout(tim);
$("#Button1").prop('disabled', true);
}
else {
sec = 60;
document.getElementById("showtime").innerHTML = "" + min + " Minutes ," + sec + " Seconds";
tim = setTimeout("f2()", 1000);
}
}
}
}
<body onload="f1()">
<div><h3>Time will be finished after:</h3>
</div>
<div id="showtime"></div>
<div> <asp:Button ID="Button1" runat="server" Text="Submit"/></div>`
</body>
MMMMMM每次刷新倒計時重啓 – Gerard
的主要問題是IM面臨:(@ashik –
此頁面時一個cookie – Owais