SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to add count down timer?

    Hi all,
    I want to add simple countdown timer for 30 sec 0r 60 sec,the time will display on the page to the users with countdown, if user is not respond with in this time, the page will be automatically redirects to the specified page...

    Give me the guidelines...
    Thanking you in advance...

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    What about ...
    Code HTML4Strict:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.2.0/build/cssreset/reset-min.css" />
        <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.2.0/build/cssbase/base-min.css" />
        <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.2.0/build/cssfonts/fonts-min.css" />
        <title>
          Counter Demo
        </title>
      </head>
      <body>
        <span id="counter">
          60
        </span>
        <script type="text/javascript" charset="utf-8">
        //<![CDATA[
          var counter = {};
          counter.tick = function(){
            var count = parseInt($('#counter').html());
            if(0 < count){
              $('#counter').html(--count);
              return;
            }
            window.location = 'http://www.google.co.uk/';
          };
          $(document).ready(function(){
            setInterval(counter.tick, 1000);
          });
        //]]>
        </script>
      </body>
    </html>

    It has a dependency on jQuery at the moment, but this should be a trivial task to refactor out.

    I'm sure one of the JavaScript gurus can help.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanking you for replying me..
    It is working fine...
    What for to go javascript guider...


Bookmarks

Posting Permissions

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