Menu DHTML script problems - timer, setTimeout, openMenu(id)

I am having problems with DHTML for my menu system.
The problem is:

  1. Go to http://www.solarinception.com.au
  2. Hover your mouse over menu items on left (Home Owners and Products)
  3. Quickly hover over 'Products' THEN continue down to 'Home Owners'.
  4. Note that one of the menu systems stays open.

You can view the script that makes this happen at:

  http://www.solarinception.com.au/includes/javascript/menu.js
  * View Page Source - to see what methods are called on the menu.

I am think this may has something to do with using a commonly declared timer. The timer is reset in the openMenu(id) call and that stops the other menu closing. The problem is I cannot find a solution.

ALL OTHER ASPECTS OF THE MENU WORK FINE!
smaccaAsked:
Who is Participating?
 
basicinstinctCommented:
replace your existing menu.js with this code:

ÿ

var timeout = 500; //in milliseconds.

 

//open menu

function openMenu(id)

{

    //cancel close timers.

    cancelCloseMenuTimer(id);

   

    //close old layer

    minimise(id);

   

    //get new layer and show it.    

    maximise(id);    

}



//close menu

function closeMenu(id)

{

   minimise(id);

}


var timers=new Object();

//close timer

function closeMenuTimer(id)

{  


    timers[id] = window.setTimeout(function(){closeMenu(id)}, timeout);

}



//cancel close timer

function cancelCloseMenuTimer(id)

{

    if (timers[id])

    {

        window.clearTimeout(timers[id]);

        timers[id] = 0;

    }

}
0
 
smaccaAuthor Commented:
Thanks BasicInstinct!

You fixed the problem (I will award points for regardless), however, a new problem has been introduced:

  http://www.solarinception.com.au

The menu does not STAY OPEN when you mouseover a submenu item.
Could you help here at all???

Cheers.
Steve
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.