TreeMenu Magic -Open Section Link Modification

There are occasions when you would like to have a Menu Section item also link to another page, perhaps an intro page for that section.

The Menu Section One link on this page has been activated to load a new page whenever the link is clicked. When the new page is loaded, Menu Section One will automatically expand to show its submenu.

Here's a code tweak that enhances the functionality of the automatic opener to include the menu section links as well:

Updated: Mar. 30, 2004

How to...

1. First, activate the menu section link. Supply an actual hyperlink to load the desired page, this will take the place of the default hash (#). The link will now look like this:

<div><a href="open_tmm_section_one.htm" onClick="P7_TMenu(this);return false">Menu Section One</a>

2. We will also need to remove the ";return false" from the onClick event of the link, otherwise nothing will happen :-) The link should now look like this:

<div><a href="open_tmm_section_one.htm" onClick="P7_TMenu(this)">Menu Section One</a>

3. Next, we'll make a code tweak to the P7_TMopen() function:

-Look for the 4th line in the script, it will look like this:

ha[i].className="p7currentmark";a=ha[i].parentNode.parentNode;while(a){

-Replace this entire line with these two lines:

if(ha[i].onclick&&ha[i].onclick.toString().indexOf("P7_TMenu")>-1){a=ha[i].parentNode;
}else{ha[i].className="p7currentmark";a=ha[i].parentNode.parentNode;}while(a){

-Be sure that this is on exactly two lines.

4. Optionally, we'll make a small tweak that will prevent the link from opening or closing when clicked. This will prevent a momentary expand-collapse of the menu section while the linked page is being loaded into the browser:

-Add this line of code to the P7_TMenu() function , add it as the first line of code in the function:

if(og==9){return;}

it should look like this:

function P7_TMenu(b,og) { //v2.5 by Project Seven Development(PVII)
if(og==9){return;}
var i,s,c,k,j,tN,hh;if(doc......

5. Save the JavaScript file.

6. Now, to activate this feature:

-add a 9 as the second argument of the P7_TMenu() behavior on the menu link, so it looks like:

onClick="P7_TMenu(this,9)

the complete <a> tag would look like this:

<div><a href="open_tmm_section_one.htm" onClick="P7_TMenu(this,9)">Menu Section One</a>

That's It!

Now the menu will automatically open to any menu section or menu link item that corresponds to the page being loaded and, if the "9" option is used, the menu will not open when clicked.

 

Tree Menu Magic by PVII
imagine the possibilities