![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| ||||||||
| ||||||||
|
|
Hi, I've looking to a solution to this problem but it seems there's none to it, or if there's one I'm yet to find it. Interesting enough the setTimeout issues and FF seem to go back to FF 1.x, they are fixed or so it seems but I have FF 2.0.0.11 and I have the same good old flicker, it works fine under IE... |
|
Here my problem I have a page with an .x3d object (validates xhtml 1.1 on the W3C) and a Javascript clock that is updated every second, the |
|
problem is that the .x3d player (Flux player plugin for FF) flicks every time the javascript clock updates, it's more annoying than really painless but if I can fix it all the merrier. Is there any other way to make a clock that will update every second without setTimeout ? |
|
//Function Time function t() { * * * * var bxx = document.getElementById('stime'); * * * * * * * * stoday = pp; * * * * * * * * intH = stoday.getHours(); * * * * * * * * intM = stoday.getMinutes(); * * * * * * * * intS = stoday.getSeconds(); |
|
* * * * if (intH < 10) { * * *h = "0"+intH; * * * * }else{h = intH;} * * * * if (intM < 10) { * * *m = "0"+intM; * * * * }else{m = intM;} * * * * if (intS < 10) { * * *s = "0"+intS; * * * * }else{s = intS;} |
|
* * * * bxx.innerHTML=h+":"+m+":"+s; |
|
* * * * stoday.setTime(stoday.getTime()+1000); * * * * var ltime = document.getElementById('ltime'); * * * * today = new Date(); * * intHours = today.getHours(); * * intMinutes = today.getMinutes(); * * intSeconds = today.getSeconds(); * * if (intHours < 10) { * * *Hours = "0"+intHours; * * }else{Hours = intHours;} * * if (intMinutes < 10) { * * *minutes = "0"+intMinutes; * * }else{minutes = intMinutes;} * * if (intSeconds < 10) { * * *seconds = "0"+intSeconds; * * }else{seconds = intSeconds;} * * timeString = Hours+":"+minutes+":"+seconds; * * ltime.innerHTML = timeString; * * * * window.setTimeout("t();", 1000); |
|
PS: If anything looks bad on my Javascript don't restrain yourself from saying it ![]() |
#3
| |||
| |||
|
#4
| ||||
| ||||
|
|
On Jan 4, 7:41*am, "scunive... (AT) gmail (DOT) com" <scunive... (AT) gmail (DOT) com wrote: |
|
function padZ(n){return (n<10)? '0'+n:''+n;} |
|
* * * * window.setTimeout("t();", 1000); setTimeout is not guaranteed to run in *exactly* 1000ms, it will run as soon after that delay as it can. Therefore, your clock will skip 2 seconds from time to time, more (and more often) if the processor is busy. |
|
You are better to see how much time of the current second is left and schedule it to run about the middle of the next second. var lag = 1050 - ms; |
![]() |
| Thread Tools | |
| Display Modes | |
| |