Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 501
  • Last Modified:

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
0
msiedle
Asked:
msiedle
1 Solution
 
Michel PlungjanIT ExpertCommented:
setTimeout does not work like that...

try

 <div class="navHeaderCursorArrow" onMouseOver="setTimeout('SwitchMenu(\'sub3\')', 1250);">Secure Login</div>
0
 
msiedleAuthor Commented:
great ...works :-)

Thanks
M
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now