Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Clock

  1. #1
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clock

    Hello guys,
    This is the javascript clock of my website
    But he load very slow.
    and in internet explore he gives error
    the content is blocked
    Someone can help me out please

    Code:
    <style type="text/css">
    #clock { font-size:1.1em; color:black; }
    </style>
    
    <script type="text/javascript">
    function updateClock (){
    var currentTime = new Date ( );
    
    //Get the hours for updating clock
    var currentHours = currentTime.getHours ();
    
    //Get the minutes for updating clock
    var currentMinutes = currentTime.getMinutes ();
    
    //Get the minutes for updating clock
    var currentSeconds = currentTime.getSeconds();
    
    // Pad the minutes and seconds with leading zeros, if required
    currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
    currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
    
    // Choose either "AM" or "PM" as appropriate
    var timeOfDay = ''; // ( currentHours < 12 ) ? "AM" : "PM";
    
    // Convert the hours component to 12-hour format if needed
    // currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
    
    // Convert an hours component of "0" to "12"
    // currentHours = ( currentHours == 0 ) ? 12 : currentHours;
    
    // Compose the string for display
    var currentTimeString = currentHours + ":" + currentMinutes + ':' + currentSeconds+ " " + timeOfDay;
    
    // Update the time display
    document.getElementById("clock").innerHTML = currentTimeString;
    }
    </script>
    </head>
    
    <body onLoad="updateClock(); setInterval('updateClock()', 1000 )">
    <span id="clock">&nbsp;</span>
    </body>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Quote Originally Posted by timmiejboi View Post
    Hello guys,
    This is the javascript clock of my website
    But he load very slow.
    and in internet explore he gives error
    the content is blocked
    Someone can help me out please
    It works fine for me in IE10 with no errors, also in Chome. Why have you marked this thread as "Resolved"? Does that mean that you no longer wish to ask this question?


    My opinion of that shot is unprintable on air. - Commentator BBC 4.
    Last edited by Philip M; 03-02-2014 at 12:41 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Philp m,

    No sorry , i think i use the wrong button for resolved :|

    But i use internet explore 10 to but i get the content error.

    i thought maybe i need to optimize this script , or update?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Quote Originally Posted by timmiejboi View Post
    Philp m,

    No sorry , i think i use the wrong button for resolved :|

    But i use internet explore 10 to but i get the content error.

    i thought maybe i need to optimize this script , or update?
    As I say, it works fine for me in IE10. There is nothing wrong with the code. You can easily test it as a free-standing script. Look elsewhere for your problem.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    LinkBacks (?)

    1. 03-02-2014, 12:36 PM

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •