Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 11:22 AM
Richard A. DeVenezia
Guest
 
Posts: n/a
Default Mozilla and setInterval

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


  #2  
Old July 20th, 2005, 11:22 AM
Richard Cornford
Guest
 
Posts: n/a
Default 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.


  #3  
Old July 20th, 2005, 11:23 AM
Lasse Reichstein Nielsen
Guest
 
Posts: n/a
Default 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.'
  #4  
Old July 20th, 2005, 11:23 AM
Laurent Bugnion, GalaSoft
Guest
 
Posts: n/a
Default 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

  #5  
Old July 20th, 2005, 11:23 AM
Richard A. DeVenezia
Guest
 
Posts: n/a
Default 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


  #6  
Old July 20th, 2005, 11:23 AM
Richard A. DeVenezia
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles