Reset setTimeout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    Reset setTimeout

    Hey,

    I posted a question yesterday that was pretty confusing. I've figured
    out some of it for myself, but there's still one issue that I can't
    figure out, and I've been trying for months now!

    I have a pop-up menu; one of those where you scroll over the menu, and
    a submenu pops up beneath it. Everything's running smoothly on every
    browser I've tested with, except for one problem on every browser: the
    "clearing" of the menu.

    The menu itself is being called by:
    onMouseOver="me nu(1)" onMouseOut="cle arIt()"

    function menu(x) let's "x" refer to a predefined array, which
    determines which menu to pop up. That menu is stored in a variable,
    showMenu. If x==0, then it changes showMenu to a whitespace, thus
    "clearing" the submenu altogether.


    clearIt() is a simple function, pasted here:
    function clearIt() { setTimeout("men u('0')", 7000) }

    The idea is that the menu will disappear after 7 seconds. The problem
    I'm having, though, is that the 7 seconds starts after the first
    onMouseOut, and doesn't restart when the visitor mouses over the
    second button. So, if I look at the first submenu for 6 seconds, then
    when I go to the second button the menu only stays open for 1 second,
    instead of starting the timer over.

    Is there any way to reset this timer? I know it can be done, since
    editors seem to be able to do it, but I can't find any reference to it
    on Google.

    TIA,

    Mike
  • Evertjan.

    #2
    Re: Reset setTimeout

    Mike wrote on 07 sep 2003 in comp.lang.javas cript:
    [color=blue]
    > function clearIt() { setTimeout("men u('0')", 7000) }
    >
    > The idea is that the menu will disappear after 7 seconds. The problem
    > I'm having, though, is that the 7 seconds starts after the first
    > onMouseOut, and doesn't restart when the visitor mouses over the
    > second button. So, if I look at the first submenu for 6 seconds, then
    > when I go to the second button the menu only stays open for 1 second,
    > instead of starting the timer over.
    >
    > Is there any way to reset this timer? I know it can be done, since
    > editors seem to be able to do it, but I can't find any reference to it
    > on Google.[/color]


    mytimeout = setTimeout("men u('0')", 7000)

    clearTimeout(my timeout)

    <http://msdn.microsoft.com/
    workshop/author/dhtml/reference/methods/cleartimeout.as p>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    Working...