Search code examples
javascripttimerdom-eventssettimeoutsetinterval

How to implement a count-down Timer on a Web Site


I want to get an website element that is always changing, such as a countdown timer that resets when someone clicks on a button. Anyone know how I can implement a constantly changing element in my C# program?


Solution

  • You can implement periodic updates using client-site Javascript functions, either setInterval() or setTimeout(), with syntax like following:

    // start digital clock
    function StartTopClock() { _pID = window.setInterval('UpdateTopClock()', 100);}
    

    which provides periodic updates every 100 ms. Detailed description is available at: http://digiclock.codeplex.com/, working demo at: http://webinfocentral.com/

    Hope this will help. Best regards,