Click to See Complete Forum and Search --> : JS function for expanding an UL


shelton
11-05-2003, 09:19 AM
On this test page, which is an example of a nested page within a site:

http://www.williamlatimer.com/council/council2.htm

I am using an expandable menu JS by Dave Lindquist. My problem is that I really need to be able to tell the nested UL of the current page to be open onload. Right now, I just have the section button of the current page highlighted and if you open that menu, the current page is bolded. i.e. the current page "Submitting a Proposal" is within the "Research" section.

Instead of trying to figure out how to pass variables, couldn't I add another function to the JS that would be referenced in the source of the current page, that tells a nested ul, by id, to be open onload?

If the answer is yes, could some kind soul give me a clue as to how to write the js to accomplish this?

Thanks in advance.

pyro
11-05-2003, 12:07 PM
You might want to try this one instead. It uses JavaScript to maximize the menu as soon as it is loaded, so it will remain accessible to those without JavaScript enabled.

http://www.infinitypages.com/research/treemenu.htm

shelton
11-05-2003, 12:35 PM
Yeah... that's an entirely different deal. Thanks for posting it.

I think mine works without JS as well, as it is comprised of UL's. So if a client doesn't have JS, or doesn't support my css, then the lists appear maximized and nested.

I'll study this one some more, but I'm thinking that the one I am using is semantically better and requires less code; accept that I don't know how to make it expand 'onload'.

pyro
11-05-2003, 12:40 PM
With CSS disabled, you are correct, the menu still displays. With JavaScript disabled in a CSS capable browser, it is an entirely different story.

As far as the semantics, you are correct. It would have been better had I written mine using lists. By the time I thought of that it was nearly finished, and I didn't have the time at the moment to fix it. Perhaps I'll be able to get around to it eventually...

Also, most of the complexity of that script comes from the fact that it will remain in the state the users last left it as they browse from page to page. I felt this would help alleviate the annoyance of having to minimize the items every time, if the structure gets complex.

shelton
11-05-2003, 12:46 PM
Oh... I didn't realize 2 things:

1. you created this script

2. that's why the cookies, the state of the menus follow as you go.

... which means that when you expand a menu and click on one of it's selections, when you get to that page, the menu stays open as you left it?

pyro
11-05-2003, 12:49 PM
Yes, that is correct.