Friday, April 29, 2011

How can I increase the time a Javascript drop-down menu remains on-screen?

Is there any way to increase the time a drop-down menu created stays on screen? The drop down menu just appears and disappears as I touch the cursor. The drop-down was created using Prototype.

From stackoverflow
  • Use a different drop down menu:

    Here's over 25 that might better suit your needs:

    Or mention what drop down menu you are using so we can at least discover the option for you!

  • Whatever function you have attached to the rolloff of the menu to make it disappear, add that code to another function and use a setTimeout() call to pause for a time before removing the menu.

    Example:

    Old Code
    var closeMenu = function() {
        $('menu').hide();
    };
    
    New Code
    var hideMenu = function() {
        $('menu').hide();
    };
    
    var closeMenu = function() {
        setTimeout(hideMenu, 5000);
    };
    

    With that change, you've now delayed the menu's disappearing act for 5 seconds. Probably don't want to take that long but you get the idea.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.