Link to home
Start Free TrialLog in
Avatar of msiedle
msiedle

asked on

Passing parameters to function from within setTimeout ?

Hi all

I've got a SwitchMenu function that hides or shows a div tag onMouseOver...and I'm trying to introduce a delay of half a second or so ...but I can't seem to pass the 'sub3' parameter to the function correctly from my code ...can someone offer advice?

This is my code without the setTimeout:
            <div class="navHeaderCursorArrow" onMouseOver="SwitchMenu('sub3')">Secure Login</div>

works fine ...

Then i try adding the setTimeout:
            <div class="navHeaderCursorArrow" onMouseOver="setTimeout('SwitchMenu()', 1250, 'sub3');">Secure Login</div>

and not working at all :-(

btw ...my SwitchMenu function is below:

                  function SwitchMenu(obj){
                        if(document.getElementById){
                        var el = document.getElementById(obj);
                        var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
                              if(el.style.display != "block"){ //DynamicDrive.com change
                                    for (var i=0; i<ar.length; i++){
                                          if (ar[i].className=="submenu") //DynamicDrive.com change
                                          ar[i].style.display = "none";
                                    }
                                    el.style.display = "block";
                              }else{
                                    el.style.display = "none";
                              }
                        }
                  }
Thanks
Mark
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of msiedle
msiedle

ASKER

great ...works :-)

Thanks
M