...

View Full Version : Help.. Countdown code don't work in Firefox



madfun
03-23-2009, 10:08 PM
Hi, can anyone help with my countdown script, it works on IE but do not
work on Firefox. I tried this method here still not working www.codingforums.com/archive/index.php/t-69468.html

Thanks,
Eugene

this is my script
-------------------


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>

<div align="center">
<center>
<table border="1" cellpadding="8" cellspacing="0" width="436">
<tr>
<td width="416" bgcolor="#000000"><font color="#FFE9B9"><!--webbot
bot="HTMLMarkup" startspan --><SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- //start

dateFuture = new Date(2009,3,21,19,1,3);

// TESTING: comment out the line below to print out the "dateFuture" for testing purposes
//document.write(dateFuture +"<br />");


//###################################
//nothing beyond this point
function GetCount(){

dateNow = new Date(); //grab current date
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
delete dateNow;

// time is already past
if(amount < 0){
document.getElementById('countbox').innerHTML="Now!";
}
// date is still good
else{
days=0;hours=0;mins=0;secs=0;out="";

amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

days=Math.floor(amount/86400);//days
amount=amount%86400;

hours=Math.floor(amount/3600);//hours
amount=amount%3600;

mins=Math.floor(amount/60);//minutes
amount=amount%60;

secs=Math.floor(amount);//seconds

if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
out += secs +" seconds";
document.getElementById('countbox').innerHTML=out;

setTimeout("GetCount()", 1000);
}
}

window.onload=function(){GetCount();}//call when everything has loaded

//-->
</script>
<div id="countbox"></div>
<!--webbot bot="HTMLMarkup" endspan --></font></td>
</tr>
</table>
</center>
</div>

</body>

</html>

Eldarrion
03-23-2009, 10:26 PM
Actually, it does work in FireFox... only the font color is... black. Coming from the following:



<td width="416" bgcolor="#000000"><font color="#FFE9B9">


Not sure exactly why you're using this kind of thing to achieve the white on black background, when you could do the following:



<style type="text/css">
td {
background-color: #000;
color: #FFF;
}
</style>


Which should work in both browsers.

Old Pedant
03-24-2009, 11:08 AM
HUH??? #FFE9B9 is closer to white than to black. Black is #000000.

The problem is, I think, the that <DIV> where he ACTUALLY puts the countdown is inside the <font>...</font> tags, and I don't think that's legal HTML. SO FF is probably just ignoring the <font> and/or is not rendering the <div>.

Isn't that the worst place to dump a bunch of JS code you've seen in a while??? Good old sloppy FP.

Eldarrion
03-24-2009, 02:43 PM
Actually, no... thing is, FF is closing the <font> tags automatically before the script output... so it comes up something like:



<font color="#FFE9B9"></font>JavaScript Output</font> (his own closing tag)


Not sure why it would do that, though I'm guessing it has to do with the whole JS being stuck in the middle of nowhere or something else along those lines. All in all, don't see why anyone would want to use a deprecated tag - that being <font color>, when the same result can be accomplished with CSS... be it with:



<td style="width: 416px; background-color: #000; color: #FFE9B9;">


or with <style> tags.

EDIT: At a second glance, what the HTML validator I use complained about was that <div> cannot be contained within a <font> tag, so that's really the main reason the <font> tag doesn't affect the text output in FF(and probably in other browsers, except for IE).

Old Pedant
03-24-2009, 09:50 PM
Yeah, what I said. <grin/>

So FF plunks the </font> in there to keep the HTML legal. That makes a weird sort of sense.

p.s.: Of course I agree with you re the use of <font>, but I also DETEST the way stupid FrontPage dumps JavaScript indiscriminately anyplace in the page. Blech.

Eldarrion
03-24-2009, 09:57 PM
p.s.: Of course I agree with you re the use of <font>, but I also DETEST the way stupid FrontPage dumps JavaScript indiscriminately anyplace in the page. Blech.

Definitely have to agree with you on the dumping JavaScript in a completely random (at least from the looks of it) location. Though maybe it makes sense for the creators of the software. (I would name them, but for any WoT fan like me... speaking the name of the devil means to call his attention to yourself, so I'll refrain from doing so)

Old Pedant
03-24-2009, 10:02 PM
Hey, even DumbWaiter does better that FoulPage on JS handling. And doesn't it strike you as slightly evil that in order to get full benefit of FancyPants you have to have FP extensions installed on the server? Again, even DW doesn't require that bit of silliness.

Eldarrion
03-24-2009, 10:20 PM
I ran FP once... about 5 or 6 years ago... and 5 minutes later, it was gone from my PC. So I had no idea about that issue... but yes, it is evil.

madfun
04-27-2009, 09:02 PM
Thanks again guys.... you rock. Could not have did it with out
your input. One silly thing I was doing wrong was changing
the script lower case to upper case.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum