Develop a digital watch using Javascript which runs on almost every browser.

Small piece of HTML and Javascript code to develop a digital watch using Javascript which executes at client side no need to write any server side script and it executes on almost every browser,We can do this in few lines of code and good thing is, there is no browser compatibility issue with this script, just copy and paste it on your notepad and save with html extension, now this is ready to Test.

Code:

<!--
    Author: Mohammad Usman
    Version: 1.0
    Technology used: HTML,Javascript
    Description: Digital Watch Using Javascript and Html.
-->
<html>
    <head>
            <title>Digital watch for every browser by Usman</title>
    </head>
    <body>        
        <script type="text/javascript">
            /*@Usman 
                Set method for every second time interval
                Parm 1(Clock) :Call custom Method to Run current Time.
                Param 2 :1000 millisecond to run watch second by second
            */
            var int = self.setInterval("clock()",1000);
            /*Clock method*/
            function clock(){
                var d=new Date();
                var t=d.toLocaleTimeString();
                document.getElementById("clock").innerHTML = "<B>" + t + "</B>";
            }
        </script>
        <div id="clock" style="text-align:center;font-size:30px;font-family:Calbiri;color:Black;background-color:rgb(207,229,236)"></div>
    </body>
</html>
Read the rest of this entry »

Comment On Facebook