javascript help please.

  • Thread starter Thread starter Steve Easton
  • Start date Start date
S

Steve Easton

How can I stop a function and then restart
it when a global variable used by the function is changed.

myfunction() works fine, but I end up
with two instances of it running when I only want one,
it is invoked using onClick =aa()
and another onClick=bb()

obtw this used in an hta but it shouldn't make
any difference.

Example:
<script>
myfunction(){
do this;
}
rate = 20000;
function aa(){
rate = 10000;
myfunction()
}
function bb(){
rate= 15000;
myfunction()
}
</script>

Thanks
Steve
 
oops, I really do have the global variable in right place:
How can I stop a function and then restart
it when a global variable used by the function is changed.

myfunction() works fine, but I end up
with two instances of it running when I only want one,
it is invoked using onClick =aa()
and another onClick=bb()

obtw this used in an hta but it shouldn't make
any difference.

Example:
<script>
rate = 20000;
myfunction(){
do this;
}
function aa(){
rate = 10000;
myfunction()
}
function bb(){
rate= 15000;
myfunction()
}
</script>
 
You can't stop a function. What you may be able to do is to have the
function itself check for a change in the variable and exit if necessary,
but the function is a set of instructions, which, once put into play, will
execute until finished.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Thanks Kevin,
Your answer sent me "Googleing" in another
direction where I found the solution.
There is a way to stop/reset a "timed" function
which is what I was looking for.

What I'm working on is a "plugin" for IE that is
launched from toolbar icon, or the Right click context menu
and that will automatically refresh a page when the page
regains "focus" ( is maximized ) from the taskbar, or also
on a selectable "timed" interval.

Now all I need to do is finish the Help page
and compile the installer.

Let me know if you want to try it, but you'll have to
run it from the desktop at this point.

Steve
 
Back
Top