SetIntervalin vbscript

Posted on 2002-07-17
Last Modified: 2010-04-09
Can anyone tell me the solution to this:
I have text fading from white to blue using the setInterval function.

I have:
fontint = setInterval("changeColor",50)

Sub changeColor()
... Then the rest of the code to change the color

It works fine but when it's finished fading I want setInterval to stop. It continues calling that function after it's finished.
Microsoft DHTML documentation says (about SetInterval):
"Returns an integer identifier representing the interval. Use this identifier to clear (stop) the interval."

I have tried setting fontint to null and zero but it makes no difference. I have also tried this:
fontint = setInterval("changeColor",0)

and this,

fontint = setInterval("",0)

Please any ideas would be very welcome.

Question by:Rhods
LVL 33

Expert Comment

ID: 7160438
instead of using setInterval, call setTimeout from the sub like this:

   sub changeColor

     'your change-color code here

     if ( notFinishedFading ) then
     end if

   end sub

and instead of this,

   fontint = setInterval("changeColor",0)

just do this

   call changeColor
LVL 22

Accepted Solution

CJ_S earned 300 total points
ID: 7164230
declare global:
dim myinterval

myinterval = setInterval("changecolor", 100)

and to stop:

LVL 22

Expert Comment

ID: 7171215
Any update?
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

LVL 53

Expert Comment

ID: 7240664
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
   In the absence of responses, I may recommend DELETE unless it is clear
   to me that it has value as a PAQ.  Silence = you don't care


LVL 53

Expert Comment

ID: 7270978
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

points to CJ_S


If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.


Expert Comment

ID: 7297712
Per recommendation, force-accepted.

CS Moderator

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now