Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts

    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?

  • #2
    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
    why are you setting the second date with the same exact information new Date() has?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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?

  • #4
    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
    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]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •