11
Hello guys I don’t understand practically anything Javascript, so for weeks I was trying to make a script that did the following:
00:00:00
1º start a countdown of 20 minutes after clicking a link.
2º And at the same time redirect to a site.
3º when passing the 20 minutes the clock would be at zero so 00:00:00 so that the user click and start counting again and redirect to post click site.
(Remember that redirects after the click and not after finishing the count!)
4º And had cookies to continue counting even after updating the page!
I couldn’t do that, but I found a script that does almost everything listed above. The only problem with the script is that it doesn’t have the link to click and start counting and doesn’t even have the cookie code to continue even after refreshing the page! Check the code below and if you know what I can do to put the link to be clicked and the cookie code
<html><head> <script language="javaScript">
var min, seg; min = 20; seg = 1
function relogio(){
if((min > 0) || (seg > 0)){
if(seg == 0){
seg = 59;
min = min - 1
}
else{
seg = seg - 1;
}
if(min.toString().length == 1){
min = "0" + min;
}
if(seg.toString().length == 1){
seg = "0" + seg;
}
document.getElementById('spanRelogio').innerHTML = min + ":" + seg;
setTimeout('relogio()', 1000);
}
else{
document.getElementById('spanRelogio').innerHTML = "00:00";
}
}
</script></head><body style="font-family:verdana;font-size:10px;" onLoad="relogio()"> <span id="spanRelogio"></span></body></html>
People I gave a change in the script and manage to put the link, but it turns out that after finishing the count it gets stuck at 00:00 and clicking again does not restart the count (I changed to 1 minute to be faster) see
<script language="javaScript">
var min, seg; min = 1; seg = 1
function relogio(){
if((min > 0) || (seg > 0)){
if(seg == 0){
seg = 59;
min = min - 1
}
else{
seg = seg - 1;
}
if(min.toString().length == 1){
min = "0" + min;
}
if(seg.toString().length == 1){
seg = "0" + seg;
}
document.getElementById('spanRelogio').innerHTML = min + ":" + seg;
setTimeout('relogio()', 1000);
}
else{
document.getElementById('spanRelogio').innerHTML = "00:00";
}
}
</script>
<a href="/" onClick="relogio(event)" target="_blank">Clique Aqui</a>
<span id="spanRelogio"></span>
Change "span" to an "a" and put "href".. and the link problem is solved ;)
– Fábio
Dude I did it, only the countdown itself became the link and also the counter was already starting itself. Then in order for the counter not to become a link I put the link below that way: <a id="spanRelogio" href="http://answall.com/" onClick="clock(Event)" target="_Blank">Click Here</a> But still the counter started alone take the test
– Márcio Sebastião
i took onload="clock() and put <a id="spanRelogio" href="http://answall.com/" onClick="clock(Event)" target="_Blank">Click Here</a> ta almost the way I want :)
– Márcio Sebastião
Hi @Marcio.Sx your question has been answered, it worked there?
– Ramos