Connecting Tech Pros Worldwide Help | Site Map

Mozilla and setInterval

Richard A. DeVenezia
Guest
 
Posts: n/a
#1: Jul 20 '05
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 Cornford
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Mozilla and setInterval


"Richard A. DeVenezia" <radevenz@ix.netcom.com> wrote in message
news:bjm6nd$kr1kl$1@ID-168040.news.uni-berlin.de...[color=blue]
>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> )[/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.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.


Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Mozilla and setInterval


"Richard A. DeVenezia" <radevenz@ix.netcom.com> writes:
[color=blue]
> 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> )[/color]

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 - lrn@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Laurent Bugnion, GalaSoft
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Mozilla and setInterval


Hi,

Lasse Reichstein Nielsen wrote:
[color=blue]
> "Richard A. DeVenezia" <radevenz@ix.netcom.com> writes:
>
>[color=green]
>>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> )[/color]
>
>
> 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[/color]

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

Richard A. DeVenezia
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Mozilla and setInterval


"Lasse Reichstein Nielsen" <lrn@hotpop.com> wrote in message
news:65k1xa93.fsf@hotpop.com...[color=blue]
> "Richard A. DeVenezia" <radevenz@ix.netcom.com> writes:
>[color=green]
> > Is some future Mozilla going to support setInterval ([/color][/color]
<function:function>,[color=blue][color=green]
> > <interval:number> ) ?
> > Right now it seems to be simply setInterval ( <function-text:string>,
> > <interval:number> )[/color]
>
> 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 - 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.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
Guest
 
Posts: n/a
#6: Jul 20 '05

re: Mozilla and setInterval


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

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


Closed Thread