+ 5

Why doesn't work

var decompte = 5; var timer = setInterval(function( ){ alert(decompte); decompte--; document.form.time.value = decompte; if (decompte <= 0) { clearInterval(timer); document.location.href = "http://google.fr"; } }, 1000); it's continue to alert (-1; -2) etc... why it doesn't go to google.fr ?

30th Sep 2017, 2:33 PM
NoxFly
NoxFly - avatar
8 Respuestas
+ 5
var decompte = 5; var timer=function(){ alert(decompte--); if(decompte<=0)document.location.href="http://google.fr"; else setTimeout(timer,250); }; timer(); then try this....? But It work fine on me...=_=
30th Sep 2017, 2:49 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 4
I think window.location.href / location.href
30th Sep 2017, 2:37 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 4
even with what you said it continue to alert 😢
30th Sep 2017, 2:42 PM
NoxFly
NoxFly - avatar
+ 4
idk ! normally when decompte reached 0 it change the page.. but it continue to alert and substract 1 from decompte... so decompte-- = -1 etc...
30th Sep 2017, 2:43 PM
NoxFly
NoxFly - avatar
+ 4
thanks, it work :)
30th Sep 2017, 2:57 PM
NoxFly
NoxFly - avatar
+ 4
Ummmm It work fine on me but not on you Problem in setInterval API on your device...? Maybe na Ahhhhh What's the main problem???
30th Sep 2017, 3:03 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 4
i just 'copy text' of your answer and I didn't see vut I forgot to erase 'then try this...?' 😂
30th Sep 2017, 3:04 PM
NoxFly
NoxFly - avatar
+ 3
But I doubt that how it count to -1,-2? 😕
30th Sep 2017, 2:42 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar