www.webdeveloper.com
Results 1 to 3 of 3

Thread: Clock

  1. #1
    Join Date
    Nov 2013
    Posts
    2

    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. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    does IE offer you to unblock scripts?
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Mar 2012
    Posts
    1,368
    Try reducing the refresh delay. E.g.

    <body onLoad="updateClock(); setInterval('updateClock()', 100 )">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles