Women in Technology

Hear us Roar



Article:
  Hierarchical Menus with the Underrated style.display Object
Subject:   improvements...
Date:   2003-05-02 10:58:56
From:   anonymous2
* first off, see the first comment for how to get the code working; the code itself is the same, the difference in the implementation is where exactly you put your link information


* secondly, this should work just fine under OS X-- Javascript is Javascript, and CSS is CSS, just make sure you have the latest browser


* third: the hideAll function isn't necessary. if you just want all of the sublinks to be hidden off the bat, first put them in a class such that display="none", so they are hidden initially.


then, change the showLevel function to the following:
function showLevel(_levelId, _imgId){
var thisLevel = document.getElementById(_levelId);
var thisImg = document.getElementById(_imgId);
if(thisLevel.style.display != "block"){
thisLevel.style.display = "block";
thisImg.src = minusImg.src;
}
else{
hideLevel(_levelId, _imgId);
}
}


(the only change is in the "if" condition)


comments &c. : tkincher@yahoo.com

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • improvements...
    2007-01-30 18:44:09  chembo [View]

    This works great. Thank you!
  • improvements...
    2004-01-01 08:33:46  anonymous2 [View]

    the hideAll() function is used to allow users who have turned off JavaScript to use the page - if you hide the 'levels' using CSS, then a user with JavaScript turned off won't be able to see them at all.