By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

setTimeout() problem?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.