Important alert: (current site time 7/15/2013 12:25:20 PM EDT)
 

VB icon

A Timer

Email
Submitted on: 8/11/2000 12:42:12 PM
By: John Oyston  
Level: Beginner
User Rating: By 3 Users
Compatibility: JavaScript
Views: 21645
(About the author)
 
     A Timer Your visitors can see exactly how long they have spent looking at your Web page.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: A Timer
' Description:A Timer Your visitors can see exactly how long they have spent looking at your Web page.
' By: John Oyston
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1918&lngWId=14'for details.'**************************************

<HTML>
<HEAD><TITLE>JavaScript Timer</TITLE>
<SCRIPT>
<!--//hide from old browsers
var counter = 0;
// call Update function in 1 second after first load
ID=window.setTimeout("Update();",1000);
function Update() {
counter ++;
//Optional alert after 10 seconds
//if (counter==10) (alert("Ten seconds is long enough!!!!"))
//Display time in status window
window.status="Elapsed time = " + counter + " seconds";
//Display time in text box
document.form1.input1.value="You have looked at this page for " + counter + " seconds";
// set another timeout for the next count
ID=window.setTimeout("Update();",1000);
}
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=aqua>
<FONT FACE=ARIAL COLOR=navy><CENTER><H1>JavaScript Timer</H1></CENTER>
JavaScript can measure time.<P>
The text value below and the status line are being updated every second.<BR>
Press the RESET button to restart the count, or the STOP button to stop it.
<HR></FONT>
<CENTER>
<FORM NAME="form1">
<INPUT TYPE="text" NAME="input1" SIZE="40" Value="Welcome!"><BR>
<INPUT TYPE="button" VALUE="RESET" onClick="counter = 0;">*
<INPUT TYPE="button" VALUE="STOP" onClick="window.clearTimeout(ID);">
</CENTER>
<HR>
<CENTER>
<FONT FACE=ARIAL COLOR=navy SIZE=4>
<A HREF="home.htm">Return to JavaScript Page</A>
<H5>John Oyston, (oyston@oyston.com), April 1997</H5></FONT></CENTER>
</BODY></HTML>


Other 25 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/23/2003 11:35:22 PM

THis Really Works n This is kool..
(If this comment was disrespectful, please report it.)

 
12/15/2009 8:22:02 PMKanderson

Thanks for your post. I had a serious mental block about how to solve a problem and this solved it for me.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.