Mozilla and setInterval

Discussion in 'Javascript' started by Richard A. DeVenezia, Sep 10, 2003.

  1. Is some future Mozilla going to support setInterval ( <function:function>,
    <interval:number> ) ?
    Right now it seems to be simply setInterval ( <function-text:string>,
    <interval:number> )

    --
    Richard A. DeVenezia
     
    Richard A. DeVenezia, Sep 10, 2003
    #1
    1. Advertising

  2. "Richard A. DeVenezia" <> wrote in message
    news:bjm6nd$kr1kl$-berlin.de...
    >Is some future Mozilla going to support setInterval
    >( <function:function>, <interval:number> ) ?
    >Right now it seems to be simply setInterval
    >( <function-text:string>, <interval:number> )


    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.com search comp.lang.javascript for my posts
    (and some of Yep's) with the keyword setTimeout (and possibly toString)
    to see example code).

    Richard.
     
    Richard Cornford, Sep 10, 2003
    #2
    1. Advertising

  3. "Richard A. DeVenezia" <> writes:

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


    It works fine with a function.

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

    /L
    --
    Lasse Reichstein Nielsen -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Sep 10, 2003
    #3
  4. Hi,

    Lasse Reichstein Nielsen wrote:

    > "Richard A. DeVenezia" <> writes:
    >
    >
    >>Is some future Mozilla going to support setInterval ( <function:function>,
    >><interval:number> ) ?
    >>Right now it seems to be simply setInterval ( <function-text:string>,
    >><interval:number> )

    >
    >
    > It works fine with a function.
    >
    > Just try
    > setInterval(function(){alert("foo");},2000);
    > (and be ready to close the window in one of the breaks).
    >
    > /L


    Why not make it more challenging?
    setInterval(function(){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
     
    Laurent Bugnion, GalaSoft, Sep 10, 2003
    #4
  5. "Lasse Reichstein Nielsen" <> wrote in message
    news:...
    > "Richard A. DeVenezia" <> writes:
    >
    > > Is some future Mozilla going to support setInterval (

    <function:function>,
    > > <interval:number> ) ?
    > > Right now it seems to be simply setInterval ( <function-text:string>,
    > > <interval:number> )

    >
    > It works fine with a function.
    >
    > Just try
    > setInterval(function(){alert("foo");},2000);
    > (and be ready to close the window in one of the breaks).
    >
    > /L
    > --
    > Lasse Reichstein Nielsen -
    > Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    > 'Faith without judgement merely degrades the spirit divine.'


    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.liftOffIn = function (N3) {
    this.N = N3
    var thisobj = this
    this.timerId = setInterval ( function () { thisobj.count() }, 1250 )
    }
    bar.prototype.count = function () {
    if (this.N<1) {
    alert ('Done')
    clearInterval (this.timerId)
    return
    }
    alert (this.N)
    this.N--
    }
    new bar (N1)
    }

    foo (5)


    --
    Richard A. DeVenezia
     
    Richard A. DeVenezia, Sep 10, 2003
    #5
  6. "Richard A. DeVenezia" <> wrote in message
    news:bjnm5l$lfdtg$-berlin.de...
    > "Lasse Reichstein Nielsen" <> wrote in message
    > news:...
    > > "Richard A. DeVenezia" <> writes:
    > >
    > >
    > > It works fine with a function.
    > >


    Yup, it sure does! The problem was this

    in Mozilla
    element.style.backgroundColor = '#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
     
    Richard A. DeVenezia, Sep 10, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Mark Bram

    SetTimeout and SetInterval - since when?

    Robert Mark Bram, Jul 10, 2003, in forum: Javascript
    Replies:
    1
    Views:
    126
    Lasse Reichstein Nielsen
    Jul 10, 2003
  2. Eli
    Replies:
    3
    Views:
    137
  3. Andrew Poulos

    'this' and setInterval

    Andrew Poulos, Nov 18, 2005, in forum: Javascript
    Replies:
    3
    Views:
    107
    Luke Matuszewski
    Nov 19, 2005
  4. Jake Barnes
    Replies:
    7
    Views:
    199
    Evertjan.
    Dec 8, 2005
  5. RgeeK
    Replies:
    5
    Views:
    144
    Jorge
    Jul 12, 2008
Loading...

Share This Page