1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Calculate and Display Time on Website

Discussion in 'Programming' started by meerkat, Mar 25, 2009.

  1. meerkat

    meerkat New Member


    I have a Javascript that calculates and displays how long, in minutes and seconds a user has been in online(Google Gears development) mode on a given web page. I need however, to modify the script so that it calculates and displays how long the user has been online on the web site. For e.g. on page 1 for 2 minutes 12 seconds. Moves to page 2 - total time on page 1 and 2= 4 minutes 13 seconds. My script (see below) starts a second counter then converts that to minutes and seconds. I have tried passing the secVar0 variable in the url but that comes back "undefined".

    Does anyone have any pointers please?

    if(request.responseText != "" && request.responseText.indexOf("404 Page not found") == -1)
            var startTicker = startCount1();
             secVar0 = startTicker;
            minVar = Math.floor(secVar0/60); 
            secVar = secVar0 % 60;        
            document.getElementById('Text1').innerHTML = "Time Online: " +" Minutes: " +minVar+" Seconds: "+ secVar; 
            document.getElementById('serverstatus').innerHTML = '<img src="online.gif">';  
  2. shabbir

    shabbir Administrator Staff Member

    Try to Store them in Cookie with some Ajax Call

Share This Page