Latest web development tutorials

Jendela clearTimeout () metode

Jendela Referensi Obyek objek jendela

Definisi dan Penggunaan

Metode clearTimeout () untuk membatalkan () setTimeout pengaturan metode timeout.

Metode parameter clearTimeout () harus ID nilai yang dikembalikan oleh setTimeout ().

tatabahasa

clearTimeout(id_of_settimeout)


Dukungan Browser

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Semua browser utama mendukung clearTimeout () metode


contoh

contoh

Contoh berikut, ada "Start menghitung!" Tombol untuk memulai timer, sebuah field input, Anda akan selalu penting, dan tombol untuk menghentikan timer "Berhenti menghitung!":

var c=0;
var t;
var timer_is_on=0;
function timedCount(){
    document.getElementById('txt').value=c;
    c=c+1;
    t=setTimeout(function(){timedCount()},1000);
}
function doTimer(){
    if (!timer_is_on){
        timer_is_on=1;
        timedCount();
    }
}
function stopCount(){
    clearTimeout(t);
    timer_is_on=0;
}

Coba »


Jendela Referensi Obyek objek jendela