PDA

View Full Version : Codice per conteggio tempo


GiacoXp
23-11-2006, 18:43
Ragazzi ho una richiesta un po strana spero che qualcuno di voi possa venire incontro ...

Mi servirebbe un codice o un'animazione che partendo da una data che decido io vaccia vedere i giorni, ore , minuti , secondi
tempo fa ho visto una pubblicità in internet fatta in flash che faceva il contdown giorno dopo giorno seconod dopo secondo

spero che tra di voi ci sia qualcuno che possa aiutarmi grazie

andbin
23-11-2006, 19:24
Ragazzi ho una richiesta un po strana spero che qualcuno di voi possa venire incontro ...

Mi servirebbe un codice o un'animazione che partendo da una data che decido io vaccia vedere i giorni, ore , minuti , secondi
tempo fa ho visto una pubblicità in internet fatta in flash che faceva il contdown giorno dopo giorno seconod dopo secondo

spero che tra di voi ci sia qualcuno che possa aiutarmi grazieLeggi <questo> (http://www.hwupgrade.it/forum/showthread.php?t=1207958) thread, c'è un mio esempio completo in HTML+Javascript.

GiacoXp
23-11-2006, 19:54
Leggi <questo> (http://www.hwupgrade.it/forum/showthread.php?t=1207958) thread, c'è un mio esempio completo in HTML+Javascript.
a me servirebbe al contrario cioè che sommi
esiste qualcosa

andbin
23-11-2006, 20:03
a me servirebbe al contrario cioè che sommi
esiste qualcosaCioè che conti i giorni/ore/ecc... passati da una certa data???

Guarda che è praticamente lo stesso concetto del mio esempio .... tecnicamente basta solo scambiare le due date nel punto in cui viene effettuata la differenza ... :D :rolleyes:
(e cambiare le varie scritte di testo, ovviamente)

GiacoXp
23-11-2006, 20:39
Cioè che conti i giorni/ore/ecc... passati da una certa data???

Guarda che è praticamente lo stesso concetto del mio esempio .... tecnicamente basta solo scambiare le due date nel punto in cui viene effettuata la differenza ... :D :rolleyes:
(e cambiare le varie scritte di testo, ovviamente)
non funziona

GiacoXp
23-11-2006, 20:49
io ho trovato quello che cerco

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>





</head>
<body >
<br /><br />
<div align="center">


<script language="JavaScript1.2">

//Dynamic countup Script- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

function setcountup(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}

//////////CONFIGURE THE countup SCRIPT HERE//////////////////

//STEP 1: Configure the date to count up from, in the format year, month, day:
//This date should be less than today
setcountup(2005,8,7)

//STEP 2: Configure text to be attached to count up
var displaymessage="da ... scoprite cosa"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countup area
var countupwidth='100%'
var countupheight='40px' //applicable only in NS4
var countupbgcolor='lightyellow'
var opentags='<font face="Verdana"><big>'
var closetags='</big></font>'

//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countup(){
if (document.layers)
document.countupnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countupie") : countupie
countup()
}

if (document.all||document.getElementById)
document.write('<span id="countupie" style="width:'+countupwidth+'; background-color:'+countupbgcolor+'"></span>')

window.onload=start_countup

function countup(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
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
paststring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(todaystring)-Date.parse(paststring)
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 (document.layers){
document.countupnsmain.document.countupnssub.document.write(opentags+"Sono passati "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+" da..." +closetags)
document.countupnsmain.document.countupnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"Sono passati "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+" da..."+closetags

setTimeout("countup()",1000)
}
</script>

<ilayer id="countupnsmain" width=&{countupwidth}; height=&{countupheight}; bgColor=&{countupbgcolor}; visibility=hide><layer id="countupnssub" width=&{countupwidth}; height=&{countupheight}; left=0 top=0></layer></ilayer>


</div>
<br /><br /><br /><br /><br /><br />



</body>
</html>


ora però mi serve un qualcosa che mi richiami questo codice che sta su una pagina web di un sito e me lo posizini su un'altra pagina web di un blog come posso fare ?

Praticamente dovrei linkare e visionare sul blog il contenuto di quella pagina in cui c'è solo quello script

andbin
24-11-2006, 10:05
non funzionaAllora ....

1) Prendi quel codice html che avevo postato in quel thread.

2) Riga 8, dove c'è var from_year = 2007; metti ad esempio 2006.

3) Riga 35, dove c'è var diff = d1 - d2; metti var diff = d2 - d1; (cioè si fa il contrario)

Dimmi un po'... ti pare così difficile??? :D :p :rolleyes:

GiacoXp
24-11-2006, 11:34
ok

ora sorge un nuovo problema xkè msn non mi accetta il codice

io avevo gia trovato un codice che fa la stessa cosa del tuo il problema è che vorrei richiamare quel codice che è contenuto in questa pagina

<frame src="http://utenti.lycos.it/giaco29/coutup.htm">

all'interno del mio post di msn ma non so come fare

tu hai qualche idea ??

Vedo che sei molto disponibile e ti ringrazio molto spero che riusciamo a venirne a capo

Grazie GXp

GiacoXp
24-11-2006, 12:59
Avrei una nuova domanda usando il codice da te indicato

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Date Countdown</title>
<script type="text/javascript">
<!--
var from_year = 2006;
var from_month = 1;
var from_day = 1;
var from_hour = 0;
var from_minute = 0;
var from_second = 0;

var d1 = new Date (from_year, from_month-1, from_day, from_hour, from_minute, from_second);

var old_second = -1;

function countdown_format (d, h, m, s)
{
return "giorni: " + d + " / " +
"ore: " + h + " / " +
"minuti: " + m + " / " +
"secondi: " + s;
}

function countdown_update ()
{
var d2 = new Date ();

var new_second = d2.getSeconds ();

if (new_second != old_second)
{
var diff = d2 - d1;
var str;

if (diff > 0)
{
var seconds = Math.floor (diff / 1000) % 60;
var minutes = Math.floor (diff / 60000) % 60;
var hours = Math.floor (diff / 3600000) % 24;
var days = Math.floor (diff / 86400000);

str = countdown_format (days, hours, minutes, seconds);
}
else
str = "Data superata!";

document.getElementById("countdown").innerHTML = str;

old_second = new_second;
}

window.setTimeout (countdown_update, 100);
}
//-->
</script>
<style type="text/css">
<!--
#info { font: normal 16px sans-serif; color: red; }
#countdown { font: bold 25px sans-serif; color: blue; }
-->
</style>
</head>
<body onload="countdown_update()">

<p>
<span id="info">
Sono trascorsi:
<b>
<script type="text/javascript">

</script>
</b>
</span>

<br>
<br>

<span id="countdown"></span>
</p>

</body>
</html>

è possibile inserire un valore Anno che ogni 365 giorni aumenta di 1

andbin
24-11-2006, 13:14
è possibile inserire un valore Anno che ogni 365 giorni aumenta di 1Certo. Se non ti importa della questione anno bisestile o meno:

var days = Math.floor (diff / 86400000) % 365;
var years = Math.floor (diff / 31536000000);Poi ovviamente ci sarebbe da modificare la funzione countdown_format().

GiacoXp
24-11-2006, 13:32
ho inserito quanto da te suggerito e modificato ma penso che manchi ancora qualcosa saresti cosi gentile da dirmi dove ho sbagliato

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Date Countdown</title>
<script type="text/javascript">
<!--
var from_year = 2006;
var from_month = 1;
var from_day = 1;
var from_hour = 0;
var from_minute = 0;
var from_second = 0;

var d1 = new Date (from_year, from_month-1, from_day, from_hour, from_minute, from_second);

var old_second = -1;

function countdown_format (y,d, h, m, s)
{
return "anni:" "+ y + " / " +
"giorni: " + d + " / " +
"ore: " + h + " / " +
"minuti: " + m + " / " +
"secondi: " + s;
}

function countdown_update ()
{
var d2 = new Date ();

var new_second = d2.getSeconds ();

if (new_second != old_second)
{
var diff = d2 - d1;
var str;

if (diff > 0)
{
var seconds = Math.floor (diff / 1000) % 60;
var minutes = Math.floor (diff / 60000) % 60;
var hours = Math.floor (diff / 3600000) % 24;
var days = Math.floor (diff / 86400000) % 365;
var years = Math.floor (diff / 31536000000);


str = countdown_format (years,days, hours, minutes, seconds);
}
else
str = "Data superata!";

document.getElementById("countdown").innerHTML = str;

old_second = new_second;
}

window.setTimeout (countdown_update, 100);
}
//-->
</script>
<style type="text/css">
<!--
#info { font: normal 16px sans-serif; color: red; }
#countdown { font: bold 25px sans-serif; color: blue; }
-->
</style>
</head>
<body onload="countdown_update()">

<p>
<span id="info">
Sono trascorsi:
<b>
<script type="text/javascript">

</script>
</b>
</span>

<br>
<br>

<span id="countdown"></span>
</p>

</body>
</html>

andbin
24-11-2006, 13:34
return "anni:" "+ y + " / " +C'è un doppio apice di troppo.

GiacoXp
24-11-2006, 13:45
cavolo che sciocco ...

grazie :D

GiacoXp
24-11-2006, 13:50
una domanda

dovrei collegare la pagina che ho creato al mio blog, che modalità ci sono per importare quella pagina in un post

cercando su internet ho trovato che

- NON DISPONIBILE - USARE IFRAME
CON WINDOWS LIVE SPACES NON è POSSIBILE USARE ALCUNI CODICI HTML COME I CODICI CHE INIZIANO CON
<iframe
<frame
<script (alcuni si alcuni no)
<neoscript
<textarea


Tu che sei un esperto che modi ci sono per ovviare a tale problema ??

andbin
24-11-2006, 13:57
- NON DISPONIBILE - USARE IFRAME
CON WINDOWS LIVE SPACES NON è POSSIBILE USARE ALCUNI CODICI HTML COME I CODICI CHE INIZIANO CON
<iframe
<frame
<script (alcuni si alcuni no)
<neoscript
<textarea


Tu che sei un esperto che modi ci sono per ovviare a tale problema ??Così è un po' tantino limitato :eek: Non so se si può fare qualcosa.:boh:
Vedo che <applet> non è elencato, quindi una applet potrebbe forse essere usata ma ... è Java ... un'altra cosa da Javascript.

Dici "<script (alcuni si alcuni no)", quali sì e quali no, giusto per sapere??

GiacoXp
24-11-2006, 15:30
si infatti è come hai detto tu

o meglio si carica ma appare una fienstra bianca con una X rossa

io ho messo

< applet http://utenti.lycos.it/giaco29/coutup.htm>

giusto

andbin
24-11-2006, 15:53
< applet http://utenti.lycos.it/giaco29/coutup.htm>No, bisognerebbe sviluppare una applet con il linguaggio Java .... che è tutta un'altra cosa.

GiacoXp
24-11-2006, 19:18
No, bisognerebbe sviluppare una applet con il linguaggio Java .... che è tutta un'altra cosa.
è complicato ?