...

View Full Version : What's up with IE and my countdown script?



Spudhead
01-03-2007, 04:31 PM
<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? :o

A1ien51
01-03-2007, 06:12 PM
why are you setting the second date with the same exact information new Date() has?

Eric

Spudhead
01-04-2007, 01:13 PM
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?

A1ien51
01-04-2007, 02:14 PM
Why don't you set the millisecond value to zero?

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

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

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum