On 18/10/2005 00:43, M B HONG 20 wrote:
Nevermind, it was a syntax error, it turns out you could just do
window.setTimeout(function1(string1), 500)
That's something entirely different. Here you're calling the function,
function1, immediately. The return value from that call will be
converted to a string and evaluated approximately 500 milliseconds
later. This can be proven with:
function myFunction() {
alert('Called');
return '';
}
setTimeout(myFunction(), 10000);
No dialog box should appear for around ten seconds, yet it will appear
immediately.
I would guess that your identifier, string1, is local to some function.
As the setTimeout function is evaluated in global scope, an error would
occur with
setTimeout('function1(string1)', 500);
because when executed, string1 won't exist. To get around that,
concatenate the value of string1 into the literal, remembering to
include nested quotes:
setTimeout('function1("' + string1 + '");', 500);
If string1 contained the value, 'my string', the code above would call
function1("my string");
approximately 500ms later.
Mike
--
Michael Winter
Prefix subject with [News] before replying by e-mail.