- Home
- Categorie
- Coding e Sistemistica
- Altri linguaggi per il web
- countdown javascript che non si ferma.
-
countdown javascript che non si ferma.
Salve a tutti, premetto che non sono molto esperto in materia e questa credo sia la sezione giusta dove postare il mio piccolo problema.
Ho uno javascript countdown che alla scadenza non si ferma e continua all'indietro.
Io vorrei poter stampare un messaggio del tipo " Tempo Scaduto " alla fine del countdown.Lo Script è il seguente:```
<!--Countdown Timer starts here-->
<script type="text/javascript">
// Description: displays the amount of time until the "dateFuture" entered below.
// NOTE: the month entered must be one less than current month. ie; 0=January, 11=December
// NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc
// format: dateFuture = new Date(year,month-1,day,hour,min,sec)
// example: dateFuture = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pmdateFuture = new Date('<?php echo $coopen_timer[0]; ?>','<?php echo ($coopen_timer[1] - 1) ; ?>','<?php echo $coopen_timer1[0]; ?>','<?php echo $coopen_timer3[0]; ?>','<?php echo $coopen_timer3[1]; ?>','<?php echo $coopen_timer3[2]; ?>');
//alert(dateFuture);
function GetCount(){
dateNow = new Date(); //grab current date
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
delete dateNow;
days=0;hours=0;mins=0;secs=0;nodays="";nohrs="";nomins="";
amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
days=Math.floor(amount/86400);//days
amount=amount%86400;
hours=Math.floor(amount/3600);//hours
amount=amount%3600;
mins=Math.floor(amount/60);//minutes
amount=amount%60;
secs=Math.floor(amount);//seconds
if(days != 0)
{
nodays = days +((days!=1)?"":"");
//alert(nodays);
document.getElementById('tot_days').innerHTML=nodays;
}
else
{
document.getElementById('tot_days').innerHTML='';
document.getElementById('days').innerHTML='';
}if(days != 0 || hours != 0)
{
nohrs = hours +((hours!=1)?"":"");
//alert(nohrs);
document.getElementById('tot_hrs').innerHTML=nohrs;
}
else
{
document.getElementById('tot_hrs').innerHTML='';
document.getElementById('hrs').innerHTML='';
}if(days != 0 || hours != 0 || mins != 0)
{
nomins = mins +((mins!=1)?"":"");
//alert(nomins);
document.getElementById('tot_mins').innerHTML=nomins;
}
else
{
document.getElementById('tot_mins').innerHTML='';
document.getElementById('mins').innerHTML='';
}document.getElementById('tot_secs').innerHTML = secs;
setTimeout("GetCount()", 1000);}
window.onload=GetCount;//call when everything has loaded
</script>
<!--Countdown Timer ends here-->Questo è il codice che stampa il countdown: <span class="color000 font18" id="tot_days"></span> <span class="color666 font18n mr10" id="days"> <?php echo $language['days']; ?> </span><span class="color000 font18" id="tot_hrs"> </span> <span class="color666 font18n mr10" id="hrs"> <?php echo $language['hr']; ?> </span> <span class="color000 font18" id="tot_mins"></span> <span class="color666 font18n" id="mins"> <?php echo $language['min']; ?> </span> <span class="color000 font18" id="tot_secs"></span> <span class="color666 font18n" id="secs"> <?php echo $language['sec']; ?> </span> Grazie per l'attenzione :)