Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di Gneve
    Registrato dal
    Dec 2005
    Messaggi
    12

    Come posso creare un . . .

    . . . conto alla rovescia ?

    Grazie!


  2. #2
    nel file Javascript (chiamalo countdown.js)
    codice:
    var montharray = new Array("Jan","Feb","Mar","Apr","May", "Jun","Jul","Aug","Sep","Oct","Nov","Dec");
    var message_on_occasion="Time out!";
    var dstring=' d ';
    var hstring=' h ';
    var mstring=':';
    var sstring='';
    
    function setcountdown(theyear,themonth,theday,thehour,themin,thesec) {
       yr=theyear;
       mo=themonth;
       da=theday;
       hr=thehour;
       min=themin;
       sec=thesec;
    }
    function countdown() {
       var today=new Date()
       var todayy=today.getFullYear()
       var todaym=today.getMonth()
       var todayd=today.getDate()
       var todayh=today.getHours()
       var todaymin=today.getMinutes()
       var todaysec=today.getSeconds()
    
       var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
       
       futurestring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec
       dd=Date.parse(futurestring)-Date.parse(todaystring)
       
       dday=Math.floor(dd/(60*60*1000*24)*1);
       dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
       dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
       dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
    
       if (dsec < 10) dsec = '0' + dsec;
       if (dmin < 10) dmin = '0' + dmin;
       if (dhour < 10) dhour = '0' + dhour;
       
       if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da) {
          crosscount.innerHTML=message_on_occasion;
          return;
       }
       if (dday<=-1) crosscount.innerHTML=message_on_occasion;
       else  crosscount.innerHTML = dday+dstring +dhour+hstring+dmin+mstring+ dsec+sstring+occasion;
       setTimeout("countdown()",1000);
    }

    dove vuoi che compaia:
    codice:
    <html>
    
    <head>
    
    
    <title>Titolo</title>
    
    <script type="text/javascript" src="countdown.js"></script>
    
    <script type="text/javascript">
       var occasion=" al MotoGP Jerez de la Frontera";
       setcountdown(2006,09,30,0,0,0);
       window.onload=countdown;
    </script>
    
    </head>
    <body onLoad='countdown()'>
    
    
      
    	<p id="crosscount"></p>
    	
    
    
    </body>
    </html>

  3. #3
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    usa titoli ben esplicativi le prossime volte (servono a velocizzare le ricerche)

  4. #4
    Utente di HTML.it L'avatar di Gneve
    Registrato dal
    Dec 2005
    Messaggi
    12
    Originariamente inviato da Xinod
    usa titoli ben esplicativi le prossime volte (servono a velocizzare le ricerche)
    Ah Ok, scusa l'errore
    Comunque grazie mille per il consiglio!


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.