469,927 Members | 1,860 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

setTimeout() problem?

hello,

could someone explain to me why the following code stops in IE with
error whereas runs smoothly in Opera (as I expect)?

function fTurn( ) {
document.write("blabla blabla<br>");
}
function fRun() { fTurn(); setTimeout('fRun()', 2000); }
fRun();

cheers,
n.
Jul 20 '05 #1
3 1225
Hello,

When you say: document.write('aaa') the script is deleted (also document)
but the timer is still installed (probably IE would fix this by killing your
timer too).
So you're erasing the fRun() function after the second call to fTurn().

--
Elias
"nobody" <no****@non.existe.nt> wrote in message
news:kW*********************@news.chello.at...
hello,

could someone explain to me why the following code stops in IE with
error whereas runs smoothly in Opera (as I expect)?

function fTurn( ) {
document.write("blabla blabla<br>");
}
function fRun() { fTurn(); setTimeout('fRun()', 2000); }
fRun();

cheers,
n.

Jul 20 '05 #2
hello,
When you say: document.write('aaa') the script is deleted (also document)
but the timer is still installed (probably IE would fix this by killing your
timer too).
So you're erasing the fRun() function after the second call to fTurn().


thanks Elias. do you have any idea why this works in Opera without
error? is there is any solution of using a construction of that kind in
IE without erasing a called function?

cheers,
n.
Jul 20 '05 #3
Try not to use document.write() to change the document's content, learn
DHTML and use the DOM (Document Object Model) to manipulate the page
dynamically.

--
Elias
"nobody" <no****@non.existe.nt> wrote in message
news:yH********************@news.chello.at...
hello,
When you say: document.write('aaa') the script is deleted (also document) but the timer is still installed (probably IE would fix this by killing your timer too).
So you're erasing the fRun() function after the second call to fTurn().


thanks Elias. do you have any idea why this works in Opera without
error? is there is any solution of using a construction of that kind in
IE without erasing a called function?

cheers,
n.

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by domeceo | last post: by
29 posts views Thread by Mic | last post: by
4 posts views Thread by Keon | last post: by
2 posts views Thread by Athanasius | last post: by
12 posts views Thread by Andrew Poulos | last post: by
28 posts views Thread by Andre | last post: by
15 posts views Thread by nikki_herring | last post: by
7 posts views Thread by Martin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.