Questa piccola javascript avverte l'utente di quanti giorrni mancano ad una predefinita data, in questo caso, 1 agosto 2003, si può inserire un testo dentro la java, ma per una preferenza, l'ho modificata. Inseribile in un testo che si voglia che il tempo trascorra. Ad esempio: mancano giorni alla partenza delle ferie del 2003 che sarà il primo agosto.
Se la inserite in una tabella potrebbe apparirvi così:
|
|
RITORNA ALLA PAGINA DELLE JAVASCRIPT
RITORNA ALLA PAGINA DEGLI OROLOGI E DATARI
utenti connessi
Autore Javascript: Mike Thompson by http://www.members.tripod.com/webdesign123now/ modified and explained from www.webmasterpaolo.com
Lo script da inserire in html
<script>
//Countdown script by Mike Thompson
//http://www.members.tripod.com/webdesign123now/
//Based on script by Website Abstraction (http://wsabstract.com)
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function countdown(yr,m,d){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var futurestring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
if (difference==0)
//change msg here
document.write("Oggi si parte!")
else if (difference>0)
//change msg here
document.write(" "+difference+" ")
}
//enter the count down date using the format year/month/day
countdown(2002,8,1)
</script>