Scroll To Top

Enter a query to search our site. Note that you can use "*" and "?" as wildcards. Enclosing more than one word in double quotes ("CSS Layout") will search for the exact phrase.

PVII Knowledge Base

1. Select a product ...
2. Select category ...
3. Search the Knowledge Base...

Question #110

In TreeMenu magic, is there any way to trigger the expansion of a menu section when a page loads when the page is NOT part of the menu?

The Answer

Prepared Oct. 2003 by Gerry Jacobsen, PVII

You can use this special JavaScript function, "P7_TMopenUrl()", on the page instead of the normal "P7_TMopen()" function on the <body> tag, onLoad event.

Note: This functionality is included and fully automated in the more recent Tree Menu Magic 2 system, which contains a complete Advanced Current Marking interface.

Here's the function:

function P7_TMopenUrl(mrk,theUrl){ //v2.5b by Project Seven Development(PVII)
  var i,x,d,hr,ha,ef,a,ag;if(document.getElementById){
  if(a.firstChild && a.firstChild.tagName=="A"){if(a.firstChild.onclick){

Here's how it works:

1. Copy and paste the new P7_TMopenUrl() function into your p7tmscript.js file.

2. In the existing <body> tag, onLoad event:

Change this:

<body onLoad="P7_TMopen()">

to this:

<body onLoad="P7_TMopenUrl(0,'MyPage.htm')">

3. Change the MyPage.htm to the actual url in the menu you wish to have triggered. For example, if the link that you wish to open is like:

<a href="">Search</a>

then you would reference the "contacts.htm" page in the function, like:

<body onLoad="P7_TMopenUrl(0,'contacts.htm')">

Page Marker Option:

In order to avoid having to create a hidden div to fool the current page marker, there is an option to the P7_TMopenUrl() function that allows you to control this automatically. The first parameter, either a 0 or a 1, will control whether the script should apply the currentmark class to the link, 0=No and 1=Yes.

So, if you leave it as zero (0), the above function would expand the menu at the position where it finds the "MyPage.htm" link, but none of the links will be marked as current. Change to a 1 and the link will be marked.

Back to the questions list