javascript - Simultaneous Clock Ticks -


i'm using jquery clock demonstrate time in application.
in application,there two different browser windows 1 of these triggers other pop window.
in these 2 windows,i'm using jclock instances,but somehow these clocks don't both tick one.

http://plugins.jquery.com/files/jquery.jclock-1.2.0.js.txt

$(document).ready(function () {       $('#clock').jclock({ format: '%d %b %a %y %h:%m:%s' }); });  <div id="clock"></div> 

why these clock not simultaneous ?
how can achieve ?
thank you

it's because jclock uses timeout interval of 1000 ms update clock view, without aligning updates 0th millisecond.

i can think of 2 workarounds:

  1. don't directly initialize jclock inside popup let parent window initialize both own , popup's jclock instances. maybe way, clocks run sync.
  2. in both main window , popup: read current milliseconds , set timeout expire after current milliseconds % 1000 ms. when timeout expires, initialize jclock. won't accurate option #1 since cannot guarantee timely firing of settimeout.

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -