When I try to run the following code in my program
setTimeout("alert('moo')", 1000);
I get the following error
Error: Object expected
Code: 800A138F
Source: Microsoft JScript runtime error
Why? Am I calling the wrong function? What I want to do is delay the execution of the subsequent function.
It sounds like you’re using
setTimeoutin a non-browser-based script (Windows Script Host or similar). You can’t do that. You can, however, useWScript.Sleepto suspend your script briefly, with which you can achieve a similar effect. Also,alertis not a WSH function; you may wantWScript.Echo. More on the WSH reference on MSDN.