X
Tap here to go to the mobile version of the site.
Your Firefox is out of date and may contain a security risk! Upgrade Firefox

Support Forum

Javascript count-up timer not working as expected

  • No replies
  • 1 has this problem
  • 66 views
Posted

I have a count-up timer in javascript. The script counts till 8 seconds and then instead of counting further, it restarts from 1. This does not occur on Chrome. Below is the code:

$(document).ready(function() {
 isTest = false;
 setInterval('showTime()', 1000);
});

function showTime()
{
 var s = parseInt($("#s").text());
 var m = parseInt($("#m").text());
 var h = parseInt($("#h").text());
 s++;
 
 if(s > 59)
 {
  s = 0;
  m++;
  if(m > 59)
  {
   m = 0;
   h++;
  }
 }
 
 if(s < 10)
 {
  s = '0' + s;
 }
 if(m < 10)
 {
  m = '0' + m;
 }
 if(h < 10)
 {
  h = '0' + h;
 }
 
 $("#s").text(s);
 $("#m").text(m);
 $("#h").text(h);
}

Modified by cor-el

Additional System Details

Application

  • User Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17

More Information

Application Basics
Name
Firefox
Version
18.0.1
User Agent
Mozilla/5.0 (Windows NT 6.0; rv:18.0) Gecko/20100101 Firefox/18.0
Build Configuration
about:buildconfig
Extensions
Name
Version
Enabled
ID
Firebug
1.11.1
true
firebug@software.joehewitt.com
avast! WebRep
7.0.1474
false
wrc@avast.com
IDM CC
7.3.3
false
mozilla_cc@internetdownloadmanager.com
Java Console
6.0.37
false
{CAFEEFAC-0016-0000-0037-ABCDEFFEDCBA}
Microsoft .NET Framework Assistant
0.0.0
false
{20a82645-c095-46ed-80e3-08825760534b}
PC Sync 2 Synchronisation Extension
1.0.0.713
false
bkmrksync@nokia.com
Important Modified Preferences
Name
Value
accessibility.typeaheadfind.flashBar
0
browser.cache.disk.capacity
358400
browser.cache.disk.smart_size.first_run
false
browser.cache.disk.smart_size.use_old_max
false
browser.cache.disk.smart_size_cached_value
358400
browser.cache.memory.capacity
16000
browser.places.smartBookmarksVersion
4
browser.privatebrowsing.autostart
true
browser.startup.homepage
http://google.co.in/
browser.startup.homepage_override.buildID
20130116073211
browser.startup.homepage_override.mstone
18.0.1
extensions.lastAppVersion
18.0.1
gfx.direct3d.prefer_10_1
true
network.cookie.prefsMigrated
true
places.database.lastMaintenance
1358600782
places.history.expiration.transient_current_max_pages
71582
privacy.cpd.offlineApps
true
privacy.cpd.siteSettings
true
privacy.sanitize.migrateFx3Prefs
true
security.warn_viewing_mixed
false
Graphics
Adapter Description
Intel(R) HD Graphics Family
Adapter Drivers
igdumdx32 igd10umd32 igd10umd32
Adapter RAM
Unknown
Device ID
0x0116
Direct2D Enabled
true
DirectWrite Enabled
true (7.0.6002.18592)
Driver Date
12-16-2010
Driver Version
8.15.10.2266
GPU #2 Active
false
GPU Accelerated Windows
1/1 Direct3D 10
Vendor ID
0x8086
WebGL Renderer
Google Inc. -- ANGLE (Intel(R) HD Graphics Family)
AzureCanvasBackend
direct2d
AzureContentBackend
direct2d
AzureFallbackCanvasBackend
cairo
JavaScript
Incremental GC
true
Accessibility
Activated
false
Prevent Accessibility
0
Library Versions
Expected minimum version
Version in use
NSPR
4.9.4
4.9.4
NSS
3.14.1.0 Basic ECC
3.14.1.0 Basic ECC
NSSSMIME
3.14.1.0 Basic ECC
3.14.1.0 Basic ECC
NSSSSL
3.14.1.0 Basic ECC
3.14.1.0 Basic ECC
NSSUTIL
3.14.1.0
3.14.1.0