I tried to post on Mozilla's forum but I ran out of space, so I'll give this a try and thanks in advance... :) Also, I've googled til I cannot google anymore, so please be kind. :D
I'm trying to call a .js file in my header where javascript would be defined, the .js file is a countdown timer that I found on the Internet a few months back and it seemed to work at the time in both Firefox and IE (still works in IE), but not in Firefox (now) and to be fair, it isn't working in Safari either. I've tested in both Win7 and XP sp3. The .js file (tzcount.js) is the following:
// start of script
// **** Time Zone Count Down Javascript **** //
/*
Visit [url]http://rainbow.arch.scriptmania.com/scripts/[/url]
for this script and many more
*/
////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////
var month = '9'; // '*' for next month, '0' for this month or 1 through 12 for the month
var day = '4'; // Offset for day of month day or + day
var hour = 19; // 0 through 23 for the hours of the day
var tz = -6; // Offset for your timezone in hours from UTC
var lab = 'tzcd'; // The id of the page entry where the timezone countdown is to show
function start() {displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);}
// ** The start function can be changed if required **
window.onload = start;
////////// DO NOT EDIT PAST THIS LINE //////////////////
function setTZCountDown(month,day,hour,tz)
{
var toDate = new Date();
if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
else if (month > 0)
{
if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
toDate.setMonth(month-1);
}
if (day.substr(0,1) == '+')
{var day1 = parseInt(day.substr(1));
toDate.setDate(toDate.getDate()+day1);
}
else{toDate.setDate(day);
}
toDate.setHours(hour);
toDate.setMinutes(0-(tz*60));
toDate.setSeconds(0);
var fromDate = new Date();
fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
var diffDate = new Date(0);
diffDate.setMilliseconds(toDate - fromDate);
return Math.floor(diffDate.valueOf()/1000);
}
function displayTZCountDown(countdown,tzcd)
{
if (countdown < 0) document.getElementById(tzcd).innerHTML = "<marquee>THE TIME HAS COME!!!</marquee>";
else {var secs = countdown % 60;
if (secs < 10) secs = '0'+secs;
var countdown1 = (countdown - secs) / 60;
var mins = countdown1 % 60;
if (mins < 10) mins = '0'+mins;
countdown1 = (countdown1 - mins) / 60;
var hours = countdown1 % 24;
var days = (countdown1 - hours) / 24;
document.getElementById(tzcd).innerHTML = days + " day" + (days == 1 ? '' : 's') + ' + ' +hours+ 'h : ' +mins+ 'm : '+secs+'s';
setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
}
}
//end of script
I have this in the header of the webpage:
<SCRIPT src="tzcount.js" type="text/javascript"></SCRIPT>
This is in the body to call the script inside of a table:
<tr>
<td></td>
<td bgcolor="#dc143c">
<center><font color="#ffffff"><SPAN id="tzcd"></SPAN></font></center></td>
<td></td>
</tr>
All that shows is a thin red line (the bgcolor for the cell).... it's suppose to display a countdown timer... this works in IE and I implore someone to try this out. If anyone has suggestions on how I can correct this, I'd appreciate it. For the record, it will work if I include the whole javascript in the header without calling the .js file, but I want it to work the .js call for portability.
Thanks,
Rob