Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

countdown script not working in Firefox and Safari 1

Status
Not open for further replies.

VBAPrincess

Programmer
Feb 6, 2004
79
US
I have a countdown script that I got from a book and it works great in IE. Firefox and Safari however do not. What do I need to do differently?

the code in the head section:
<script language="JavaScript">
<!-- hide script from old browsers
now = new Date

Uvote = new Date (now.getYear(), 2,5)
if (Uvote.getTime() < now.getTime()){
Uvote.setYear(Uvote.getYear()+1)
}

function dayToDays(inTime) {
return (Math.floor(inTime.getTime() / (1000 * 60 * 60 * 24)))
}

function daysTill(inDate) {
return dayToDays(inDate) - dayToDays(now)
}
// end hiding script from old browsers -->
</script>

The code in the body where the value goes:

<script language="JavaScript">
<!-- hide script from old browsers
document.write(daysTill(Uvote) + " DAYS UNTIL VOTE")
// end hiding script from old browsers -->
</script>

TIA for any and all help!!!


Diana
VBA Princess
-- I'm hoping to grow up to be a Goddess!
 
Your post has convinced me of 2 things:

1) You need to get the money back for your book.
2) I should write a javascript book.

Here's a quick fix to your code:
Code:
    now = new Date[!]();[/!]
    
    Uvote = new Date (now.get[!]Full[/!]Year(), 2,5)[!];[/!]
    if (Uvote.getTime() < now.getTime()){
       Uvote.setYear(Uvote.getYear()+1)[!];[/!]
    }

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
I'll preorder a copy of your book kaht.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Webflo
 
Get about 1000 more people to post that and I'll actually write it, dwarfthrower [lol]

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
THANK YOU kaht! At least the book was borrowed from a friend so I didn't actually spend money on it. :) (oh, and the copyright on the book is 1998 so perhaps it would have actually worked just fine 10 years ago!)

Diana
VBA Princess
-- I'm hoping to grow up to be a Goddess!
 
Ahh... looks like I missed one:
Code:
Uvote.setYear(Uvote.get[!]Full[/!]Year()+1);

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top