[Free script] JavaScript ticking clock

Started by Xhanch Studio, April 03, 2011, 07:15:03 PM

previous topic - next topic
Go Down

Xhanch Studio

Another free script from Xhanch Studio that will display a running/ticking digital clock on your web page or on your browser's title and status. The time will be displayed based on visitor's local computer time.

This script can be run well using Mozilla Firefox (any version), Internet Explorer (any version), Opera and Fast Browser.

Code Select
        <title>Ticking Clock</title>
        <script language="JavaScript">
            // By   : Xhanch Studio
            // URL  : http://xhanch.com

            function start_clock(){
               dt = new Date;

               dt_hh = dt.getHours();
               if(dt_hh.toString().length == 1)
                   dt_hh = "0"   dt_hh;

               dt_mm = dt.getMinutes();
               if(dt_mm.toString().length == 1)
                   dt_mm = "0"   dt_mm;

               dt_ss = dt.getSeconds();
               if(dt_ss.toString().length == 1)
                   dt_ss = "0"   dt_ss;

               dt_str = dt_hh   ":"   dt_mm   ":"   dt_ss;

               //Displaying the digital clock
               //Choose one of these three options

               //First option - diplay it in the browser title
               document.title = dt_str;
               //End of first option

               //Second option - diplay it in the status bar
               window.status = dt_str;
               //End of second option

               //Second option - diplay it in a HTML element
               element_id.value = dt_str;
               //End of second option

    <body onload="start_clock()">
        <input type="text" size="15" id="element_id"/>

Demo: http://xhanch.com/javascript-ticking-clock/
Best Regards,
Susanto B.Sc
Web development services, WordPress plugin and theme development, PSD to XHTML conversion - http://xhanch.com
Read free manga online - http://authrone.com

Go Up