私はasp.net VBを使用しているコードによって呼び出されるjavascriptのカウントダウンタイマーを持っています。私は時間を追跡する方法を見つけることができません。ASP.NET JavaScriptタイマー
問題があります。私は、ポストバックの後に経過した時間を得ることができないので、タイマーは継続します。私を助けてくれますか?私はそれを本当に感謝し、ここで
は、私のコードの断片である:私はあなたの問題はあなたのことだと思う
function mySubmit()
{
document.getElementById('TimerTxtbx').removeAttribute('disabled');
}
function countdown_clock()
{
var current_time;
current_time = document.getElementById('TimerTxtbx').value;
var hours = current_time.substring(0,2);
var minutes = current_time.substring(3,5);
var seconds = current_time.substring(6,8);
var n_seconds;
var n_minutes = minutes;
var n_hours = hours;
if (seconds == 0)
{
n_seconds = 59;
if (minutes == 0)
{
n_minutes = 59;
if (hours == 0){
alert('Time is up');
return;
}
else{
n_hours = hours - 1;
if (n_hours < 10)
n_hours = "0" + n_hours;
}
}
else
{
n_minutes = minutes - 1;
if (n_minutes < 10)
n_minutes = "0" + n_minutes;
}
}
else
{
n_seconds = seconds - 1;
if (n_seconds < 10)
n_seconds = "0" + n_seconds;
}
document.getElementById('TimerTxtbx').value = n_hours + ':' + n_minutes + ':' + n_seconds;
setTimeout("countdown_clock()",1000); //function call and delay by 1sec
document.getElementById('TimerTxtbx').setAttribute('disabled','disabled');
}//end function
あなたが抱えている問題は、それがポストバックの上に一定の時間を正確に何を保っているのですか? あなたがそこに置いたコードは、最初のページの読み込みにはうってつけです。ポストバックではありません。 –
はい、それは実際に問題です。私はポストバックの後に経過した時間を得ることができません。手伝ってくれませんか。、? –
申し訳ありませんが、最初に私がコードを投稿したときにそれを詳しく説明していない場合。あなたのアルゴリズムと私のものは同じです(^ _ ^)。あなたは私のポストをもう一度見ることができます。私は編集しました(^ _ ^)、。 –