Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here



Helpful Links

How to use timers in HTML by Targol
Posted: 30 Oct 02 (Edited 30 Oct 02)

To add timers capabilyties to an html page, you'v got to use the window.setInterval method. It's interface is this one :

oInterval=window.setInterval(FctToCall, TimeWait)
  FctToCall :
string containing the name of the function to call
  TimeWait :
Time to wait (in milliseconds) before calling FctToCall
Here is an exemple :

<Script language="Jscript">
var oInterval;

function RemindMsg(msg) {
  oInterval=window.setInterval("ShowDelayedMsg('" + msg + "')", 2000);
  // function stopTimer() will be called every 2 seconds
  // Note that you can add any parameters to the function call.

function ShowDelayedMsg(msg) {
  var oDiv=document.getElementById("container");
  var oldContent = oDiv.innerHTML;
  var curDate=new Date();
  oDiv.innerHTML = oldContent + curDate + " : " + msg + "<BR>";

function stopTimer() {
  // the timer is now stopped
  <input type="button" value="start timer" onclick="RemindMsg('another message');"/>
  <input type="button" value="stop timer" onclick="stopTimer();"/>
  <div id="container"></div>

Back to HTML, XHTML & CSS FAQ Index
Back to HTML, XHTML & CSS Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close