Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to show javascript timer on web page

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 123
    Comment on it

    Hello Reader's if you are developing the portal where you want to show user the coundown time. Then this blog is usefull to your. Let's see how to make an auto counter in Javascript:- first create a html file and name it count.html and code will go like this:-

     <!DOCTYPE html>
        <html>
        <body>        
        <p>Count numbers: <output id="result"></output></p>
        <button onclick="StartMyCountdown()">Click to start times</button> 
        <button onclick="StopMyCountdown()">Click to stop</button>    
        </body>
        </html>
    

    Now the Javascript for the file will go like this:-

    <script>
    var start;
    
    function StartMyCountdown() {
        if(typeof(Worker) !== "undefined") {
            if(typeof(start) == "undefined") {
                w = new Worker("demo&#95;workers.js");
            }
            w.onmessage = function(event) {
                document.getElementById("result").innerHTML = event.data;
            };
        } else {
            document.getElementById("result").innerHTML = "This browser is not supporting";
        }
    }
    
    functionStopMyCountdown() { 
        start.terminate();
        start = undefined;
    }
    </script>
    

    Now on loading this page you will see a start button, when you click that button a timer will start showing the seconds which will start below it. And when user will click on stop timer the timer will stop at that time. This function can be used in online examination or booking services where you have to keep the timer events.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: