Grow your CSS skills. Land your dream job.

hide submenu onload

  • # October 4, 2012 at 4:07 pm

    Hello!

    I inherited an accordion style menu and can’t quite figure out how to make it all collapsed on load.

    Please see http://www.siphon-marketing.com/unifirst/V3/level2.html and you’ll notice the menu on the left.

    I’m used to working with menus and accordions in the typical ul/li format and this one has got me stumped!

    Can anybody help me out?

    Len

    # October 5, 2012 at 12:05 am

    hmmm, that is some heavy javascript there, WAY more work than it needs to be…

    but there is a function available you can call:

    leftnavMenu.prototype.collapseAll = function() {
    for (var i = 0; i < this.submenus.length; i++)
    if (this.submenus.className != "collapsed")
    this.collapseMenu(this.submenus
    );
    };

    In the HTML file at the top you should be able to find this:

    var myMenu;
    window.onload = function() {
    myMenu = new leftnavMenu("my_menu");
    myMenu.init();
    };

    After the line

    myMenu.init();

    add this line:

    myMenu.collapseAll();

    that should work…else, you could do:

    body onload="myMenu.collapseAll();"
    # October 5, 2012 at 7:41 am

    Heya!

    This worked perfectly in Firefox but, unfortunately, not IE! Any ideas?

    By the way…I’ve moved the page to http://www.siphon-marketing.com/unifirst/V3/level2.html

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".