Javascript to display time on Web page

Javascript to display continuous time on the Web page. By continuous it means that it will be displayed second by second.

    <script type="text/javascript">
        function ShowTime()
        {
            var dt = new Date();
            document.getElementById("<%= TextBox1.ClientID %>").value = dt.toLocaleTimeString();
            window.setTimeout("ShowTime()", 1000);
        }
       
            
    </script>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


If you are using normal Webform then it can be called on Body load event. If you are using MasterPage then it can be called within ContentTemplate at the end afte all the controls will be rendered.

10 Comments

Comments have been disabled for this content.