Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript in Firefox

    Attached is a Text file showing code for an HTML page and its related JavaScript. The JS draws a Calendar and a Clock in the bottom left hand corner of the webpage. The code runs fine in IE. If, however, the Clock is below the Calendar, Firefox will move the Clock incrementally down the page every second (as the clock updates) - appearing to make the Calendar move upwards.

    Any ideas as to why/how to cure this?

    (FWIW the VBScript that randomises the background is included in the attachment.)
    Attached Files Attached Files
    Gre

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: JavaScript in Firefox

    I think the insertion of the extra <td> tag was causing a problem. This fixed it in my test:

    <pre>function showtime () {
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var monthOffset = ' + (monthOffset || 0) + ';
    //tmp='<td>';
    tmp='';
    tmp+=((hours < 10) ? "0" : "")+hours;
    tmp+='<span id="blinker1">:</span>'+ ((minutes < 10) ? "0" : "")+minutes;
    tmp+='<span id="blinker2">:</span>'+ ((seconds < 10) ? "0" : "")+ seconds; //+ '</td>';
    document.getElementById("clockgoeshere").innerHTML =tmp;
    timerID = setTimeout("showtime()",1000);
    timerRunning = true;
    }</pre>

    Obviously that can be cleaned up... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: JavaScript in Firefox

    Thanks very much. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15> You're quite right. That's what comes from sticking (& adjusting) a number of separate scripts together.

    (As you may have noticed, the blinker1 & blinker2 functions were removed. They put asynchronous "blinks" on the time separators. Great effect, but unfortunately took up masses of CPU!)
    Gre

Posting Permissions

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