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 01-03-2007, 03:31 PM   PM User | #1
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
What's up with IE and my countdown script?

Code:
<script type="text/javascript">
function updateCountdown(){
	var today	= new Date();    //today's date
	var today2	= new Date(today.getFullYear(), today.getMonth(), today.getDate(), today.getHours(), today.getMinutes(), today.getSeconds());
	var launch	= new Date(2007, 0, 8, 0, 0, 0);    //Launch date
	var diff	= launch-today2;    //difference in milliseconds
	var seconds	= new String(diff/1000);    //calculate seconds and convert to string
	document.getElementById("countDown").innerHTML = "<p>That's only " + seconds + " seconds away.</p>";
	setTimeout("updateCountdown()",1000);
}
</script>

Ok, it's not pretty but... well, it works in Firefox, it works in Opera, there's no warnings or anything. In IE7 (Win) I get an error message on the line:

var today = new Date(); //today's date

that tells me simply "unknown runtime error". And no countdown appears.

Am I being a muppet again?
Spudhead is offline   Reply With Quote
Old 01-03-2007, 05:12 PM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
why are you setting the second date with the same exact information new Date() has?

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Old 01-04-2007, 12:13 PM   PM User | #3
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
Quote:
Originally Posted by A1ien51 View Post
why are you setting the second date with the same exact information new Date() has?

Eric
New Date() will give me a millisecond value, that I don't need and that would give me a decimal number of seconds when I divide the millisecond count by 1000. I want an integer. Yes, I know I can just cInt it but hey, I didn't say it was pretty. Why would that be related to an "unknown runtime error" message?
Spudhead is offline   Reply With Quote
Old 01-04-2007, 01:14 PM   PM User | #4
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
Why don't you set the millisecond value to zero?

http://www.w3schools.com/jsref/jsref...lliseconds.asp

for the run time, I have no clue, is all of the whitespace throwing IE off? you never know. LOL

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 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 01:48 PM.


Advertisement
Log in to turn off these ads.