Calculate and Display Time on Website

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

  1. meerkat

    meerkat New Member

    Joined:
    Mar 25, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    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?
    Thanks,
    meerkat



    Code:
    if(request.responseText != "" && request.responseText.indexOf("404 Page not found") == -1)
        {
            c=0;
            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

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Try to Store them in Cookie with some Ajax Call
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice