Mozilla and setInterval

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard A. DeVenezia

    Mozilla and setInterval

    Is some future Mozilla going to support setInterval ( <function:funct ion>,
    <interval:numbe r> ) ?
    Right now it seems to be simply setInterval ( <function-text:string>,
    <interval:numbe r> )

    --
    Richard A. DeVenezia


  • Richard Cornford

    #2
    Re: Mozilla and setInterval

    "Richard A. DeVenezia" <radevenz@ix.ne tcom.com> wrote in message
    news:bjm6nd$kr1 kl$1@ID-168040.news.uni-berlin.de...[color=blue]
    >Is some future Mozilla going to support setInterval
    >( <function:funct ion>, <interval:numbe r> ) ?
    >Right now it seems to be simply setInterval
    >( <function-text:string>, <interval:numbe r> )[/color]

    Mozilla does support passing a function reference as the first argument
    to both setTimeout and setInterval.

    A compatibility trick with setTimeout and setInterval is to use
    exclusively function references and provide the function referred to
    with its own toString method that returns a string of JavaScript source
    code that would call the function via some global identifier. If the
    setTimout/Interval function implementation does not support function
    reference arguments it type-converts the function into the expected
    string by calling its toString method. Allowing the more efficient
    function references to be used where supported and providing a fallback
    when unsupported. (I have posted a number of examples over the last 3 or
    4 months so groups.google.c om search comp.lang.javas cript for my posts
    (and some of Yep's) with the keyword setTimeout (and possibly toString)
    to see example code).

    Richard.


    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Mozilla and setInterval

      "Richard A. DeVenezia" <radevenz@ix.ne tcom.com> writes:
      [color=blue]
      > Is some future Mozilla going to support setInterval ( <function:funct ion>,
      > <interval:numbe r> ) ?
      > Right now it seems to be simply setInterval ( <function-text:string>,
      > <interval:numbe r> )[/color]

      It works fine with a function.

      Just try
      setInterval(fun ction(){alert(" foo");},2000);
      (and be ready to close the window in one of the breaks).

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Laurent Bugnion, GalaSoft

        #4
        Re: Mozilla and setInterval

        Hi,

        Lasse Reichstein Nielsen wrote:
        [color=blue]
        > "Richard A. DeVenezia" <radevenz@ix.ne tcom.com> writes:
        >
        >[color=green]
        >>Is some future Mozilla going to support setInterval ( <function:funct ion>,
        >><interval:num ber> ) ?
        >>Right now it seems to be simply setInterval ( <function-text:string>,
        >><interval:num ber> )[/color]
        >
        >
        > It works fine with a function.
        >
        > Just try
        > setInterval(fun ction(){alert(" foo");},2000);
        > (and be ready to close the window in one of the breaks).
        >
        > /L[/color]

        Why not make it more challenging?
        setInterval(fun ction(){alert(" foo");},20);

        ;-)

        --
        Laurent Bugnion, GalaSoft
        Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
        Private/Malaysia: http://mypage.bluewin.ch/lbugnion
        Support children in Calcutta: http://www.calcutta-espoir.ch

        Comment

        • Richard A. DeVenezia

          #5
          Re: Mozilla and setInterval

          "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
          news:65k1xa93.f sf@hotpop.com.. .[color=blue]
          > "Richard A. DeVenezia" <radevenz@ix.ne tcom.com> writes:
          >[color=green]
          > > Is some future Mozilla going to support setInterval ([/color][/color]
          <function:funct ion>,[color=blue][color=green]
          > > <interval:numbe r> ) ?
          > > Right now it seems to be simply setInterval ( <function-text:string>,
          > > <interval:numbe r> )[/color]
          >
          > It works fine with a function.
          >
          > Just try
          > setInterval(fun ction(){alert(" foo");},2000);
          > (and be ready to close the window in one of the breaks).
          >
          > /L
          > --
          > Lasse Reichstein Nielsen - lrn@hotpop.com
          > Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
          > 'Faith without judgement merely degrades the spirit divine.'[/color]

          This is a 'simplified' version of what I thought wasn't working, but dangit,
          it works.

          function foo (N1) {
          function bar (N2) {
          this.liftOffIn (N2)
          }
          bar.prototype.l iftOffIn = function (N3) {
          this.N = N3
          var thisobj = this
          this.timerId = setInterval ( function () { thisobj.count() }, 1250 )
          }
          bar.prototype.c ount = function () {
          if (this.N<1) {
          alert ('Done')
          clearInterval (this.timerId)
          return
          }
          alert (this.N)
          this.N--
          }
          new bar (N1)
          }

          foo (5)


          --
          Richard A. DeVenezia


          Comment

          • Richard A. DeVenezia

            #6
            Re: Mozilla and setInterval

            "Richard A. DeVenezia" <radevenz@ix.ne tcom.com> wrote in message
            news:bjnm5l$lfd tg$1@ID-168040.news.uni-berlin.de...[color=blue]
            > "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
            > news:65k1xa93.f sf@hotpop.com.. .[color=green]
            > > "Richard A. DeVenezia" <radevenz@ix.ne tcom.com> writes:
            > >
            > >
            > > It works fine with a function.
            > >[/color][/color]

            Yup, it sure does! The problem was this

            in Mozilla
            element.style.b ackgroundColor = '#FFFF00';
            alert (element.style. backgroundColor ); // shows rgb (255,255,0)

            Seeing how my function scheduled to run expected #rrggbb when reading the
            color back, it was destined to break when it came across the rgb()
            translation Mozilla so nicely did.

            --
            Richard A. DeVenezia


            Comment

            Working...