Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8027905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:57:35+00:00 2026-06-04T23:57:35+00:00

I have problem with setTimeout. In all major browsers it works fine but not

  • 0

I have problem with setTimeout.

In all major browsers it works fine but not in IE…
I’m creating a facebook app- puzzle. When player press Start button, the timer starts count his time of playing one game.
At the beginning I used setInterval to increase timer but with cooperate of facebook scripts it delayed about 2 seconds at the end of game. Then I found on stackoverflow trick to increase accuracy of timer: setInterval timing slowly drifts away from staying accurate
And again- without facebook it worked fine, no delays were shown. With facebook it still has delays.
Now to condensate info that might interest You:
When user clicks Start then I create new Date as startTime.
When user ends game script creates finalTime new Date, then substract finalTime – startTime.

In code there is setTimeout:

(...)    

f : function() {
        var sec_time = Math.floor((puzzle.nextAt - puzzle.startTime)/1000);
        $('.timer').html(sec_time);
        if (!puzzle.startTime) {
            puzzle.startTime = new Date().getTime();
            puzzle.nextAt = puzzle.startTime;
            $('.timer').html('0');
        }
        puzzle.nextAt += 100;
        puzzle.to = setTimeout(puzzle.f, puzzle.nextAt - new Date().getTime());
    }

(...)    

when user place on correct place last puzzle piece then I call clearTimeout(puzzle.to);

I have now 2 issues:

  1. not accurate time, in IE it can be even 7 second difference!

  2. in IE during game it works only when user have mousedown… :/

To drag puzzles I use jQuery drag & drop plugin.
At least very helpful info will be how to achieve accurate timer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:57:37+00:00Added an answer on June 4, 2026 at 11:57 pm

    You should put your scripts in jQuery’s ready function and not at the bottom of the page, as the Facebook SDK is loaded asynchronously and may impact timed executions if they’re initiated at the bottom of the page.

    As for timing, you’re gonna see inaccuracy of between 15ms and 45ms in IE7 depending on other JS executions on the page. Your 100ms timeout will drift badly because of this. Better to record a start time and build a timer with a higher polling frequency than needed and do a comparison between start time and ‘now’ in each cycle to determine what to do next.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JQuery/Ajax update. It correctly updates in all major browsers, however, dealing
I have a problem using AJAX .post in Internet Explorer. In all other browsers,
Apparently many people have run into this problem, but I have yet to be
I have a Greasemonkey script that works just fine in Firefox and Opera. I
I have a problem with javascript functions setTimeout() and setInterval() functions. Basicly my function
welcome all , i have a problem with my images slider , it runs
I have problem with consuming DbContext class in EF 4.3 CodeFirst approach. As for
I have problem with building in Qt4 creator. I have some created projects and
i have problem to pass data from view to controller , i have view
I have problem with empty item(s) in accordion UI. I have 3 sections. +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.