bigbang01 Posted June 8, 2009 Share Posted June 8, 2009 Hi, I've got the following error with this external script code running under Windows XP: setTimeout("test()",5000);function test(){ WScript.Echo("Hello world\n"); } Runtime error: Script C:\...\test.jsLine:1 Char: 1 Error: Object expected Code: 800A138F Source: Microsoft JScript runtime errorIf I write "test();" instead of "setTimeout..." it's OK.Any hint to fix this up? Thank you. Link to comment Share on other sites More sharing options...
bigbang01 Posted June 8, 2009 Author Share Posted June 8, 2009 Solution found by using WScript.Sleep(5000) instead of setTimeout. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2009 Share Posted June 8, 2009 Correct, setTimeout is a method of the window object. The Windows Script Host does not create a window object. Link to comment Share on other sites More sharing options...
bigbang01 Posted June 9, 2009 Author Share Posted June 9, 2009 Smart comment. Thank you. Link to comment Share on other sites More sharing options...
Synook Posted June 10, 2009 Share Posted June 10, 2009 It is worth remembering that all JS methods called (in the browser) without a related object are methods of the window instance created when the page loads. In effect, this is like having all your code surrounded by with(window) { ... }. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.