www.webdeveloper.com
Results 1 to 2 of 2

Thread: Countdown Till Update

  1. #1
    Join Date
    Sep 2012
    Posts
    1

    Question Countdown Till Update

    Hi,

    I was wondering how I'd be able to make this:

    This website will update in 60 seconds.

    Just with normal text but the 60 counts downwards.

    Not sure if it needs to be Javascript but, I know it definitely works with Javascript so I put it here (Moderators, Feel free to move this topic if I'm wrong!). I know it's probably really easy to do it but, I don't know much coding at all xD I just stick to using drag and drop systems (Much easier).

    Thanks in advance!

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,377

    Lightbulb

    Modified from: http://forum.codecall.net/topic/5163...in-javascript/
    which you could find with a simple search...

    Code:
    <!doctype html>
    <html>
    <head>
    <script type="text/javascript">
    var Timer;
    var TotalSeconds;
    
    function CreateTimer(TimerID, Time) {
      Timer = document.getElementById(TimerID);
      TotalSeconds = Time;
            
      UpdateTimer()
      window.setTimeout("Tick()", 1000);
    }
    
    function Tick() {
      TotalSeconds -= 1;
      if (TotalSeconds > 0) {
        UpdateTimer()
        window.setTimeout("Tick()", 1000);
      } else {
        Timer.innerHTML = 'Site (to be) updated';
    // change redirected URL on next line and uncomment
    //  window.location.href = 'http://www.webdeveloper.com';
      }
    }
    
    function UpdateTimer() {
      Timer.innerHTML = 'Site will be updated in: '+TotalSeconds+' seconds';
    }
    </script>
    </head>
    
    <body onload="CreateTimer('timer',10)">
    <div id='timer' />
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles