این کد مدت زمان حضور شما را در سایت را در lable نشان میدهد

 

 

<script language="JavaScript">

var timerID = 0;
var tStart  = null;
var s=0;
var a=0;


function UpdateTimer() {
s=s+1;
if (s==60){a=a+1;}
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }

   if(!tStart)
      tStart   = new Date();

   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();
   tDate.setTime(tDiff);

   document.theTimer.theTime.value = "" + a+ ":"  + tDate.getSeconds();
  
   timerID = setTimeout("UpdateTimer()", 1000);
}

function Start() {
   tStart   = new Date();

   document.theTimer.theTime.value = "00:00";
   timerID  = setTimeout("UpdateTimer()", 1000);
}

function Stop() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }

   tStart = null;
}

function Reset() {
   tStart = null;

   document.theTimer.theTime.value = "00:00";
}
</script>
<body onload="Reset()" onunload="Stop()">
<center><form name="theTimer"><table>
   <tr>
      <td colspan=3 align=center>
         <input type=text name="theTime" size=5>
      </td>
   </tr>
   <tr><td></td></tr>
   <tr>
      <td>
         <input type=button name="start" value="Start" onclick="Start()">
      </td>
      <td>
         <input type=button name="stop" value="Stop" onclick="Stop()">
      </td>
      <td>
         <input type=button name="reset" value="Reset" onclick="Reset()">
      </td>
   </tr>
</table></form></center>