SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Non-Member deathshadow's Avatar
    Join Date
    Jul 2006
    Dublin, NH
    0 Post(s)
    0 Thread(s)

    Javascript timer differences

    For some time I've noticed that IE and FF respond WILDLY different to Timeouts - after some testing I noticed that FF seems to run timeouts almost unthrottled if you set it below 60ms - and above 60ms it seems to respond about 50% over what I'm asking for...

    While IE always ticks reasonably accurate at 15ms or faster, and as low as 10ms if the computer in question is fast enough...

    I'm wondering if I should attempt to correct the number I'm feeding firefox using a sniffer, or if I should write a 'timer monitor' to compare against the system clock, and adjust the amount I'm moving around elements on the screen so that they go the same distance in the same time regardless of browser (or at least close enough most users wouldn't notice)... any input on the timers in browsers and their use would be most welcome.

    For those curious, this is what I'm working on, a fun little side project to see how far I can push the graphical boundaries of html/javascript without resorting to SVG or Flash.
    *** warning *** loads lots of images before it starts functioning, so may take a bit to load (the images are small, but ping times can be murder)... no collision detection yet, arrow keys move you around.

    It can also 'lose' images and have to reload them from time to time if your browser cache is too small... I'm probably just going to rewrite in SVG once I have a command of that down halfway decent.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    West Springfield, Massachusetts
    198 Post(s)
    3 Thread(s)


    I recently found out that the settimeout function has a "mystery" argument that is different in different browsers. I think I saw a bug report dealing with really long time intervals calling it the "delay" argument (or something like that). This page calls it the "lateness" argument.
    I don't think you can "force" a value for the argument, the browsers "add" it.
    But you may be able to access the value from within your function and deal with it there.
    Or maybe you could try setinterval instead, although it may have the "mystery' argument too.
    As for losing images, images have a complete property. Although support for this has been described as "dodgy", you can test for it and if false reload the image. It may not be 100% dependable, but unless you have a real lot of images it should help.


Posting Permissions

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