setTimeout() problem?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nobody

    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('fRu n()', 2000); }
    fRun();

    cheers,
    n.
  • lallous

    #2
    Re: setTimeout() problem?

    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" <nobody@non.exi ste.nt> wrote in message
    news:kWBBb.2078 88$361.117506@n ews.chello.at.. .[color=blue]
    > 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('fRu n()', 2000); }
    > fRun();
    >
    > cheers,
    > n.[/color]


    Comment

    • nobody

      #3
      Re: setTimeout() problem?

      hello,
      [color=blue]
      > 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().[/color]

      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.

      Comment

      • lallous

        #4
        Re: setTimeout() problem?

        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" <nobody@non.exi ste.nt> wrote in message
        news:yHCBb.2081 37$361.61829@ne ws.chello.at...[color=blue]
        > hello,
        >[color=green]
        > > When you say: document.write( 'aaa') the script is deleted (also[/color][/color]
        document)[color=blue][color=green]
        > > but the timer is still installed (probably IE would fix this by killing[/color][/color]
        your[color=blue][color=green]
        > > timer too).
        > > So you're erasing the fRun() function after the second call to fTurn().[/color]
        >
        > 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.[/color]


        Comment

        Working...