Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-23-2009, 09:08 PM   PM User | #1
madfun
New to the CF scene

 
Join Date: Mar 2009
Location: Los Angeles, CA
Posts: 4
Thanks: 3
Thanked 0 Times in 0 Posts
madfun is an unknown quantity at this point
Smile Help.. Countdown code don't work in Firefox

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 http://www.codingforums.com/archive/...p/t-69468.html

Thanks,
Eugene

this is my script
-------------------
Code:
<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>

Last edited by Kor; 03-24-2009 at 01:52 PM.. Reason: wrap the code [code][/code]
madfun is offline   Reply With Quote
Old 03-23-2009, 09:26 PM   PM User | #2
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Actually, it does work in FireFox... only the font color is... black. Coming from the following:

Code:
<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:

Code:
<style type="text/css">
td {
    background-color: #000;
    color: #FFF;
}
</style>
Which should work in both browsers.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Users who have thanked Eldarrion for this post:
madfun (04-27-2009)
Old 03-24-2009, 10:08 AM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
madfun (04-27-2009)
Old 03-24-2009, 01:43 PM   PM User | #4
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Actually, no... thing is, FF is closing the <font> tags automatically before the script output... so it comes up something like:

Code:
<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:

Code:
<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).
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?

Last edited by Eldarrion; 03-24-2009 at 03:05 PM..
Eldarrion is offline   Reply With Quote
Old 03-24-2009, 08:50 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 03-24-2009, 08:57 PM   PM User | #6
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Quote:
Originally Posted by Old Pedant View Post
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)
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 03-24-2009, 09:02 PM   PM User | #7
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 03-24-2009, 09:20 PM   PM User | #8
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
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.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 04-27-2009, 08:02 PM   PM User | #9
madfun
New to the CF scene

 
Join Date: Mar 2009
Location: Los Angeles, CA
Posts: 4
Thanks: 3
Thanked 0 Times in 0 Posts
madfun is an unknown quantity at this point
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.
madfun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:21 AM.


Advertisement
Log in to turn off these ads.