setTimeout() problem?

N

nobody

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.
 
L

lallous

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().
 
N

nobody

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.
 
L

lallous

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top