2016-12-14 4 views
0

Ich habe Probleme mit der Funktion confirm(). Es scheint die setTimeout() Funktion zu ignorieren und ruft sich sofort auf.Wie kann man eine JS-Funktion nicht selbst aufrufen?

Ich möchte die Funktion warten, bis die 600 Sekunden vor dem Aufruf erfolgt.

function stillThere() { 
 
    if(confirm("Your session has expired. Are you still here?")){ 
 
\t  //Continue 
 
    } else{ 
 
    \t window.location.href = "../logout.php"; 
 
    } 
 
} 
 

 
setTimeout(stillThere, 600);

+0

Es berufen sich nach ' – Rayon

+3

setTimeout' Sie setzen 600 ms, nicht 600 zweite –

Antwort

2

Der Timeout-Parameter für setTimeout ist Zahl in Millisekunden

function stillThere(){ 
 
    if(confirm("Your session has expired. Are you still here?")){ 
 
     //Continue 
 
    }else{ 
 
    \t window.location.href = "../logout.php"; 
 
    } 
 
} 
 

 
// 1 second = 1000 ms 
 
// 600 seconds = 600000 ms 
 
setTimeout(stillThere, 600000);

+0

Haha! Ich kann mir selbst nicht glauben! Danke, dass du es gelöst hast! –

Verwandte Themen