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 6721349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:19:11+00:00 2026-05-26T09:19:11+00:00

So I made a simple timer in a format like this: MM:SS.MS You can

  • 0

So I made a simple timer in a format like this: MM:SS.MS

You can view it here [removed]
It works fine in chrome, IE, etc. but in Firefox the seconds are like twice as long..

I took a look at some other stopwatches, but I don’t quit understand them.
Whats the best way to do it ? Right now I have a 10ms interval which generates the timer.

The function looks like that, I hope it’s understandable:

var state = false;
var msTimer = null;

var min = document.getElementById("min");
var sec = document.getElementById("sec");
var ms = document.getElementById("ms");

var minCount = 0;
var secCount = 0;
var msCount = 0;


document.onkeydown = function timer(e) {

if (!e) { e = window.event; }

if (e.keyCode == "32") {

    if (state == false) {
        state = true;

        min.innerHTML = "00";
        sec.innerHTML = "00";
        ms.innerHTML = "00";

        msTimer = window.setInterval(function() {
            if (msCount == 99) {

                msCount = 0;
                secCount++;

                // Minutes
                if (secCount == 60) {

                    secCount = 0;
                    minCount++;

                    if (minCount <= 9)
                    { min.innerHTML = "0" + minCount; }
                    else
                    { min.innerHTML = minCount; }
                }

                // Seconds
                if (secCount <= 9)
                { sec.innerHTML = "0" + secCount; }
                else
                { sec.innerHTML = secCount; }

            } else { msCount++; }

            // Miliseconds
            if (msCount <= 9)
            { ms.innerHTML = "0" + msCount; }
            else
            { ms.innerHTML = msCount; }

            // 1 Hour
            if (minCount == 60) {

                clearInterval(msTimer);

                min.innerHTML = "N0";
                sec.innerHTML = "00";
                ms.innerHTML = "0B";

                state = false;

                minCount = 0;
                secCount = 0;
                msCount = 0;
            }
        }, 10);

    } else if (state == true) {
        state = false;

        clearInterval(msTimer);

        minCount = 0;
        secCount = 0;
        msCount = 0;
    }
}

Thanks for any advices 🙂

Edit:

And btw, it’s much smoother in firefox, if I remove all styles from the timer.
But that can’t be the solution..

  • 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-05-26T09:19:12+00:00Added an answer on May 26, 2026 at 9:19 am

    You shouldn’t be relying on the interval of the timer being exactly 10ms. It would be better if you viewed each timer tick as a request to refresh the on-screen timer, but take the measurements from the system clock or something like that.

    Then however slow or busy the machine (and JS implementation) is, you’ll always see an accurate timer1 – just one which updates less often.


    1 This will only be as accurate as the system clock, of course. If Javascript has access to a high-performance timer like .NET’s Stopwatch class or Java’s System.nanoTime() method, that would be better to use.

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

Sidebar

Related Questions

I have made a simple timer but in trying to increase the timers speed
I made a simple counter, but it increments by 2 instead of 1. $handle
Can any one help me. I have this ‘unmanaged’ .NET code, which works on
The idea is pretty simple: Where the timer is made in Javascript, when it
I'm pretty new to all this. I've read through the forums, but can't seem
I have made a simple app to try a nut out the problem; this
I would like to have a simple query that I can run against a
Here is a simple Tell a Friend form I made in HTML, it's correctly
On Windows, testing different OSes is made simple using VMs. Is there a simple
We made a simple application and using GoogleAppEngineLauncher (GAEL) ran that locally. Then we

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.