MyBB Community Forums

Full Version: My Javascript won't show up?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.

I found a code on the Javascript Kit website for a countdown script which I want to put at the top of my forum. I am therefore editing the template for the page header. Here is the code I am adding below the two bars at the top of the page:

<script>

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


//change the text below to reflect your own,
var before="Valentines day!"
var current="Today is Valentines day. Don\'t forget the flowers!"
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)
document.write(current)
else if (difference>0)
document.write("Only "+difference+" days until "+before)
}
//enter the count down date using the format year/month/day
countdown(2002,2,14)
</script>

I know its not MyBB's job to work out if anything is wrong with the script. So what I want to know is whether the forum software is blocking this from working, or whether the script is just broken?

My Forum: http://forum.yrea.org.uk/
The Script: http://www.javascriptkit.com/script/script2/count.shtml

Thanks in advance Smile
MyBB isn't going to stop it working in itself, there's either an error with the code or it's conflicting with the MyBB javascript. As I don't get any javascript errors on your site, it would seem it's the former.
Do you know of a code which works 100% that I can try?