Count Down

Discussion in 'JavaScript' started by crazyryan, Dec 16, 2007.

  1. #1
    Hi

    Basically I want to show a message saying "Your content will be shown in 5 seconds".

    Whether or not there is a real live countdown, it doesn't matter, although I'd prefer it.

    After 5 seconds passes I want to show a piece of text for example.

    Can anyone help me?
     
    crazyryan, Dec 16, 2007 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">

    var start=new Date();
    start=Date.parse(start)/1000;
    var counts=10;
    function Count(){
    var now=new Date();
    now=Date.parse(now)/1000;
    var x=parseInt(counts-(now-start),10);
    if(document.form1){document.form1.clock.value = x;}
    if(x>0){
    timerID=setTimeout("Count()", 100)
    }else{
    document.write("Hello");
    }
    }

    </script>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    window.setTimeout('Count()',100);
    -->
    </script>
    </HEAD>
    </head>
    <BODY>


    </center>
    <FORM NAME="form1">
    You are being redirected in
    <INPUT TYPE="text" NAME="clock" SIZE="2" VALUE="10">
    seconds.
    </FORM>
    </center>



    </body>
    </html>
     
    kmap, Dec 16, 2007 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    Hey - how does that code work?
     
    crazyryan, Dec 16, 2007 IP
  4. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #4
    yes it works

    Did you tried it

    just create a html file and open that in internet explorer

    It will give you warning allow the content

    Regards

    Alex
     
    kmap, Dec 16, 2007 IP
  5. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #5
    kmap, Dec 16, 2007 IP
  6. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #6
    It works but when the countdown finishes it still continues loading something.. :s
     
    crazyryan, Dec 16, 2007 IP
  7. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #7
    it does not load anything after countdown
     
    kmap, Dec 16, 2007 IP
  8. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #8
    My page continues loading something after..
     
    crazyryan, Dec 16, 2007 IP
  9. funforums

    funforums Well-Known Member

    Messages:
    1,406
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    140
    #9
    Script is working fine, When countdown stops you will see the text " Hello " but it keeps loading.
     
    funforums, Dec 16, 2007 IP
  10. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #10
    No it doest not ...

    Try the link i gave you in firefox

    Regards

    Alex
     
    kmap, Dec 16, 2007 IP
  11. funforums

    funforums Well-Known Member

    Messages:
    1,406
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    140
    #11
    Don't know about crazyryan, But i am using Firefox and it happens to me.
     
    funforums, Dec 16, 2007 IP
  12. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #12
    ok this is happening in firefox try in internet explorer


    Regards

    Alex
     
    kmap, Dec 16, 2007 IP
  13. pubdomainshost.com

    pubdomainshost.com Peon

    Messages:
    1,277
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Or maybe if you could specify what do you wish to achieve at the end of countdown.. like redirect to a URL ? or what ... that may help .. to help you ..
    Thanks
    GS
     
    pubdomainshost.com, Dec 16, 2007 IP
  14. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #14
    Basically I want to countdown to show a <div>

    Although, I need it fine in all browsers.
     
    crazyryan, Dec 16, 2007 IP
  15. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #15
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    var start=new Date();
    start=Date.parse(start)/1000;
    var counts=10;
    function Count(){
    var now=new Date();
    now=Date.parse(now)/1000;
    var x=parseInt(counts-(now-start),10);
    if(document.form1){document.form1.clock.value = x;}
    if(x>0){
    timerID=window.setTimeout("Count()", 100);
    }else{
    location.href="http://www.ukrate.com/ebooks";
    }
    }

    window.setTimeout("Count()", 100);

    </script>

    </HEAD>

    <BODY>


    <center>
    <FORM NAME="form1">
    You are being redirected in
    <INPUT TYPE="text" NAME="clock" SIZE="2" VALUE="10">
    seconds.
    </FORM>
    </center>



    </body>
    </html>
     
    kmap, Dec 16, 2007 IP
  16. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #16
    kmap, Dec 16, 2007 IP