please dont rip this site


Method. Evaluates an expression after a specified number of milliseconds has elapsed.


timeoutID=setTimeout(expression, msec)


timeoutID is an identifier that is used only to cancel the evaluation with the clearTimeout method.

expression is a string expression or a property of an existing object.

msec is a numeric value, numeric string, or a property of an existing object in millisecond units.

Method of

Frame object, window object

Implemented in

Navigator 2.0


The setTimeout method evaluates an expression after a specified amount of time. It does not evaluate the expression repeatedly. For example, if a setTimeout method specifies five seconds, the expression is evaluated after five seconds, not every five seconds.

When passing arguments to a function within a setTimeout or setInterval call, wrap it in an anonymous function, e.g. this.setTimeout(function(){myfunc(a,b,c)}, 100)

Never pass a simple or concatenated string as the first argument of a setTimeout or setInterval call. A string will be evaluated in exactly the same way as an eval call, including the associated performance impact. For this reason, pass an anonymous function or a callback instead


Example 1. The following example displays an alert message five seconds (5,000 milliseconds) after the user clicks a button. If the user clicks the second button before the alert message is displayed, the timeout is canceled and the alert does not display.

function displayAlert() {
   alert("5 seconds have elapsed since the button was clicked.")
Click the button on the left for a reminder in 5 seconds;
click the button on the right to cancel the reminder before
it is displayed.
<INPUT TYPE="button" VALUE="5-second reminder"
<INPUT TYPE="button" VALUE="Clear the 5-second reminder"

Example 2. The following example displays the current time in a Text object. The showtime function, which is called recursively, uses the setTimeout method to update the time every second.

var timerID = null
var timerRunning = false
function stopclock(){
   timerRunning = false
function startclock(){
   // Make sure the clock is stopped
function showtime(){
   var now = new Date()
   var hours = now.getHours()
   var minutes = now.getMinutes()
   var seconds = now.getSeconds()
   var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
   timeValue += ((minutes < 10) ? ":0" : ":") + minutes
   timeValue += ((seconds < 10) ? ":0" : ":") + seconds
   timeValue += (hours >= 12) ? " P.M." : " A.M."
   document.clock.face.value = timeValue
   timerID = setTimeout("showtime()",1000)
   timerRunning = true

<BODY onLoad="startclock()">
<FORM NAME="clock" onSubmit="0">
   <INPUT TYPE="text" NAME="face" SIZE=12 VALUE ="">

See also

clearTimeout method

See also:

file: /Techref/inet/iis/jscript/htm/settimeout.htm, 4KB, , updated: 2009/7/24 10:13, local time: 2018/2/21 00:13,

 ©2018 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE! / 

<A HREF=""> setTimeout</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2018 contributors:
o List host: MIT, Site host, Top posters @20180221 RussellMc, Sean Breheny, Van Horn, David, David C Brown, Darron Black, Harold Hallikainen, alan.b.pearce, Isaac M. Bavaresco, John Gardner, Mario,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!