473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Jul 20 '05 #1
5 8855
"Richard A. DeVenezia" <ra******@ix.netcom.com> wrote in message
news:bj************@ID-168040.news.uni-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.
Jul 20 '05 #2
"Richard A. DeVenezia" <ra******@ix.netcom.com> 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 - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Hi,

Lasse Reichstein Nielsen wrote:
"Richard A. DeVenezia" <ra******@ix.netcom.com> 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

Jul 20 '05 #4
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:65**********@hotpop.com...
"Richard A. DeVenezia" <ra******@ix.netcom.com> 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 - lr*@hotpop.com
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
Jul 20 '05 #5
"Richard A. DeVenezia" <ra******@ix.netcom.com> wrote in message
news:bj************@ID-168040.news.uni-berlin.de...
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:65**********@hotpop.com...
"Richard A. DeVenezia" <ra******@ix.netcom.com> 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
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Joseph Misko | last post by:
I am on WinXP. The following page works perfectly in IE6. For Netscape 7.0, I have to move off of the image and then back on to get the fade to take effect, and with Mozilla (latest version) a...
5
by: Ivan Marsh | last post by:
Hey Folks, This code works in IE but not in Mozilla. I'd like it to work in both. I'm sure it has something to do with the way I'm passing the anchor object but I can't figure it out. ...
17
by: George Hester | last post by:
Hoe can I use setInterval where its argument is a function which also has an argument? For example I have a function change(Msg) where Msg is dynamically generated and returns nothing at this point...
3
by: Eli | last post by:
Hello all, I have just added a small piece of JavaScript code to a basic HTML page of mine. At the end of the page (after the closing </HTML>) I added: <SCRIPT LANGUAGE="JavaScript">...
1
by: John Smith | last post by:
Can you tell me why Mozilla can't show some Javascript? example: function high(which2){ theobject=which2 highlighting=setInterval("highlightit(theobject)",50) } function low(which2){...
1
by: Caledonia_558 | last post by:
Hi everyone, I'm having trouble with a bit of code to make a paragraph of text change colour every second to a new, random colour: Here's the script's function: <script type="text/javascript">...
6
by: marktm | last post by:
Hi- I am trying to use setInterval to call a method within an object and have not had any luck. I get "Object doesn't support this property or method" when I execute the following code. What I...
1
by: rajesh | last post by:
var fixedX = -1 // x position (-1 if to appear below control) var fixedY = -1 // y position (-1 if to appear below control) var startAt = 0 // 0 - sunday ; 1 - monday var showWeekNumber =...
3
by: shawn | last post by:
Hi All Was trying to get this bit of code working (simplified of course) for (i=0;i<uuid_num;i++) { window.setInterval(InitMap(uuidValues), timePeriod); } Where uuid_num, uuidValues,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.