Tuesday, April 10, 2012

Clock visitor time visiting the page

<script LANGUAGE="JavaScript">

startday = new Date();
clockStart = startday.getTime();

function initStopwatch()
{
 var myTime = new Date();
 return((myTime.getTime() - clockStart)/1000);
}
 

function getSecs()
{
 var tSecs = Math.round(initStopwatch());
 var iSecs = tSecs % 60;
 var iMins = Math.round((tSecs-30)/60);  
 var sSecs ="" + ((iSecs > 9) ? iSecs : "0" + iSecs);
 var sMins ="" + ((iMins > 9) ? iMins : "0" + iMins);
 document.forms[0].timespent.value = sMins+":"+sSecs;
 window.setTimeout('getSecs()',1000);
}

</script>

<BODY onLoad="window.setTimeout('getSecs()',1)">

<CENTER>

<FORM>
<FONT SIZE="2" FACE="Arial">Time spent here: </FONT><input size=5 name=timespent>
</FORM>

</CENTER>

Print button for page


<script LANGUAGE="JavaScript">

if (window.print)
{
 document.write('<form> '
+ '<input type=button name=print value="Click" '
+ 'onClick="javascript:window.print()"> To Print this page!</form>');
}
 
</script>

Back and Forward button


<script LANGUAGE="JavaScript">

function  
goHist(a)

{
  history.go(a);
}


</script>

< form
METHOD="post">
< input type="button" value="BACK" onClick="goHist(-1)">
< input type="button" value="FORWARD" onClick="goHist(1)">
< /form>