Avatar billede smask Nybegynder
11. februar 2007 - 23:59 Der er 7 kommentarer

lige et problem med et counter Javascript

hej,

Jeg har lige fundet dette som jeg gerne vil have på min side.

<script>

/*
Count up from any date script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/

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

function countup(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 paststring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)
difference+=" days"
document.write("It\'s been "+difference+" since the launch of JavaScript Kit!")
}
//enter the count up date using the format year/month/day
countup(1997,12,05)
</script>

<p align="center"><font face="arial" size="-2">This free script provided by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
Kit</a></font></p>

Scriptet virker fint, men jeg vil gerne bruge det samme script 2 steder på min side. Og hvis jeg paster det ind to steder, så virker ingen af dem.

Kan man ændre noget for at den kan virke begge steder?

Tak ;)
Avatar billede jhe-ting Nybegynder
12. februar 2007 - 04:30 #1
Placer dette i HEAD
-------------------

<script>

/*
Count up from any date script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/

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

function countup(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 paststring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)
difference+=" days"
document.write("It\'s been "+difference+" since the launch of JavaScript Kit!")
}
</script>


Indsæt en udgave af dette hvert sted du ønsker:
------------------------------------------------

<script>
//enter the count up date using the format year/month/day
countup(1997,12,05)
</script>


Indsæt en udgave af dette hvert sted du ønsker:
------------------------------------------------



<p align="center"><font face="arial" size="-2">This free script provided by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
Kit</a></font></p>
Avatar billede smask Nybegynder
12. februar 2007 - 05:23 #2
hej igen.

kan det laves saa jeg kan ændre indholdet begge steder?

f.eks.
i den første viser jeg hvor længe mit website har været oppe - og i den anden viser jeg hvor længe siden jeg har røget min sidste cigaret ;)

jeg mener - sådan som du viser det der, vil den tælle det samme begge steder.
Avatar billede smask Nybegynder
12. februar 2007 - 05:24 #3
jeg mener - det er ikke denne jeg vil ændre:

<script>
//enter the count up date using the format year/month/day
countup(1997,12,05)
</script>

det er denne her:
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)
Avatar billede smask Nybegynder
12. februar 2007 - 05:26 #4
sry denne vil jeg ændre:

<script>

/*
Count up from any date script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/

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

function countup(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 paststring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)
difference+=" days"
document.write("It\'s been "+difference+" since the launch of JavaScript Kit!")
}
</script>
Avatar billede smask Nybegynder
12. februar 2007 - 05:31 #5
ja. og så var det sgu ikke engang den rigtige jeg havde givet dig.. undskyld.. men det er denne her:


<!--Simply copy and paste into <BODY>  </BODY>
where you want this message it to appear.-->

<SCRIPT type="text/javascript">

/*
Count Up - Script
Visit http://rainbow.arch.scriptmania.com/scripts/
for this script and many more
*/

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(2001,10,18)

//STEP 2: Configure text to be attached to count up
var displaymessage="have passed since my last cigarette!"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countup area
var countupwidth='350px'
var countupheight='35px'
var countupbgcolor='lightblue'
var opentags='<font face="Verdana" color="blue"><small>'
var closetags='</small></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+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags)
document.countupnsmain.document.countupnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+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><p><font face="arial" size="-2">This free script provided by </font><br><font face="arial, helvetica" size="-2"><a href="http://rainbow.arch.scriptmania.com/scripts/">Rainbow Arch</a></font></p>
Avatar billede roenving Novice
25. februar 2007 - 18:14 #6
Lukketid ?-)
Avatar billede jhe-ting Nybegynder
26. februar 2007 - 04:58 #7
Det du fandt frem til "12/02-2007 05:31:12" er ret gammeldags.
Jeg synes et mere moderne (VALIDERNDE) eksempel ville være bedre.

Se eksemplet: http://heiltech.homepage.dk/exp/CountUp.htm
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester