home *** CD-ROM | disk | FTP | other *** search
/ PC User 2005 May / CD / PCU0505CD.iso / software / full / coffecup / files / html2005.exe / %MAINDIR% / Javascript / TimeSpent.xml < prev    next >
Encoding:
Text File  |  2005-02-16  |  1.2 KB  |  52 lines

  1. <ccResource>
  2.   <ccTitle>
  3. Time Spent
  4.   </ccTitle>
  5.   <ccCategory>
  6. Clocks
  7.   </ccCategory>
  8.   <ccDescription>
  9. This scripts tell your sites visitor how long they spent at the page.
  10.   </ccDescription>
  11.   <ccInstructions>
  12.  
  13.   </ccInstructions>
  14.   <ccHeadContent>
  15.   <SCRIPT LANGUAGE="JavaScript">
  16. <!-- Begin
  17. startday = new Date();
  18. clockStart = startday.getTime();
  19. function initStopwatch() { 
  20. var myTime = new Date(); 
  21. return((myTime.getTime() - clockStart)/1000); 
  22. }
  23. function getSecs() { 
  24. var tSecs = Math.round(initStopwatch()); 
  25. var iSecs = tSecs % 60;
  26. var iMins = Math.round((tSecs-30)/60);   
  27. var sSecs ="" + ((iSecs > 9) ? iSecs : "0" + iSecs);
  28. var sMins ="" + ((iMins > 9) ? iMins : "0" + iMins);
  29. document.forms[0].timespent.value = sMins+":"+sSecs;
  30. window.setTimeout('getSecs()',1000); 
  31. }
  32. // End -->
  33. </script>
  34.   </ccHeadContent>
  35.   <ccBodyContent>
  36.  
  37. <CENTER>
  38. <FORM>
  39. <FONT SIZE="2" FACE="Arial">Time spent here: </FONT><input size=5 name=timespent>
  40. </FORM>
  41. </CENTER>
  42.   </ccBodyContent>
  43.   <ccElementContent>
  44.   
  45.    <ccElementName>onLoad</ccElementName>
  46.    <ccElementAction>window.setTimeout('getSecs()',1)</ccElementAction>
  47.    
  48.   </ccElementContent>
  49.   <ccExtraData>
  50.  
  51.   </ccExtraData>
  52. </ccResource>