Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:52

How to open automatically the menu to pagematch node ?


Poster: davidarnoult
Dated: Thursday February 24 2005 - 15:54:10 GMT

Hi guys,

A simple question : how to make the menu automatically opened to the page match node deeper than the first level ? the pagematch works good but shows only first level highlights, you have to mouse over to open level 2...

how can the menu be opened to the exact node (_itemRef I guess). I have seen an auto open function but that's not what I am looking for...

I hope I am clear enough...

Very good product by the way, I have bought it and I do not regret my choice !

Looking forward answers.

David


Poster: Ruth
Dated: Thursday February 24 2005 - 23:08:54 GMT

I'm not sure I understand what you want to do. Are you asking that the menu with the reference to the page you are on be and stay open when you reach the page?

Ruth


Poster: davidarnoult
Dated: Friday February 25 2005 - 6:44:31 GMT

Yes exactly, the menu stay opened with the item highlighted matching the page. Is is possible to do that ?

Rgds

David


Poster: Ruth
Dated: Friday February 25 2005 - 7:09:04 GMT

Hi David,
The only way I know to do that would be with the auto open subs. Its purpose is to have the submenu that refers to that page open when you reach that page [or any other page you reach in that submenu] and it would then be highlighted, if you have the pagebgcolor and pagecolor set to do that.
Since you said you didn't want the auto open function you saw, I think I may be misunderstanding. Do you have a site with the menu? You could then tell us what to click to get to a particular page, and what you want it to look like when we get there.

Ruth


Poster: davidarnoult
Dated: Friday February 25 2005 - 8:53:31 GMT

Hi,

Thanks for your help : could you give me the link to this au open sub, I can't find out anymore.

The web site is not online yet, but I will publish the address when it will be.

Thks

David


Poster: davidarnoult
Dated: Friday February 25 2005 - 9:49:51 GMT

I have found it but problem : my menu is fully horizontal (on 2 lines) and once the menu is open according the current page (and that works), it doesn't manage the mouse over on the others menu ! how can I make it close when I go on the other menus ?

Thanks

David


Poster: Ruth
Dated: Friday February 25 2005 - 10:15:54 GMT

Hi David,
First you need to post your menu code here, the menu_data.js file codes. No one will be able to help with the issue unless they can use your data file having the menu layout the way you have it.
I am not a code person. Kevin did this function. I will post a note to him to look at this thread. But he will need your menu_data.js codes. You can post that using the code button above to open and then close the post.
You will also need to make sure you are using the newest update, that is 5.715 I believe, because that is what we use when we test.
I'm sorry I can't be more help. I'll post right now for Kevin. I don't know what his schedule is.

Ruth


Poster: davidarnoult
Dated: Friday February 25 2005 - 10:46:20 GMT

OK here is my code, I am with latest release 5.715
:

Code:
<script language="JavaScript">
<!--
_menuCloseDelay=1000           // The time delay for menus to remain visible on mouse out
_menuOpenDelay=1000            // The time delay before menus open on mouse over
_subOffsetTop=0              // Sub menu top offset
_subOffsetLeft=0            // Sub menu left offset

// mm_separator is the separator string to be placed between
// menu item names in the output to the page.  Edit this
// to suit your taste.

var mm_separator = "<tr><td height=1 bgcolor='#DADBDB'></td></tr>";


// mm_selectionSequenc is the sequence of selected menu items
// that led to the last selected item.  Rebuilt when the page
// loads by the getSelectionSequenc() function

var mm_selectionSequence = "";


// mm_openUrl() is called to go to the next page.  It automatically
// passes the _itemRef (last active menu item) to the next page

function mm_openUrl(url)
{
  url+="?menu="+_itemRef;
  window.location.href = url;
}


// mm_getSelectionSequence extracts the _itemRef from the parameter
// passed in the url, then figures out the sequence of menu items
// that led to it.  Called at the bottom of this file so that it
// runs automatically when the page loads and after the menus are
// drawn


function mm_getSelectionSequence()
{

  var urls = location.search
  if (urls.lastIndexOf("menu=") > 0 ) {
     var param=urls.substring(urls.lastIndexOf("menu="));
     var selectedItem = param.substring(5,param.length);
     var i = selectedItem;
  }
  else {
   var i = '<%=Session("menu")%>';
  }
 
 
  do {
    if (mm_selectionSequence == "")
      mm_selectionSequence = '<tr><td>&nbsp;' + _mi[i][1] + '</td></tr>';
    else
      mm_selectionSequence = '<tr><td>&nbsp;' + _mi[i][1] + '</td></tr>' + mm_separator + mm_selectionSequence;
    i = getParentItemByItem(i);
  } while (!isNaN(i));
}

function resetSubmenus()
{
  for (i = 1; i < _m.length; i++)
  {
    if (_m[i][7]) {
      _m[i][7] = 0;
      _m[i][3] = null;
      _m[i][2] = null;
    }
  }
}

function autoOpenSubmenu()
{
  //topOffset = 40;
  resetSubmenus();
  var urls = location.search
  if (urls.lastIndexOf("menu=") > 0 ) {
     var param=urls.substring(urls.lastIndexOf("menu="));
     var clickedItemNum = param.substring(5,param.length);
   //alert(clickedItemNum);
  }
   
  mainItemNum = getParentItemByItem(clickedItemNum);
  clickedItemPos = gpos(gmobj("el" + mainItemNum));
  menuNum = getMenuByItem(clickedItemNum);
  menuObj = gmobj("menu" + menuNum);
  menuPos = gpos(menuObj);
  //alert (menuPos[1]);
  //menuPos[0] = clickedItemPos[0] - menuPos[2] + topOffset;
  menuPos[1] = clickedItemPos[1];
  spos(menuObj,105,menuPos[1]);
  _m[menuNum][7] = 1;
  popup(_mi[mainItemNum][3]);
}


function elem(url,title) {
   this.url = url;
   this.title = title;
}

var Menu = new Array();
Menu[0] = new elem("/fr/index.asp",'Accueil');
Menu[1] = new elem("/fr/products/",'Produits');
Menu[2] = new elem("/fr/services/",'Services');
Menu[3] = new elem("/fr/partners/",'Partenaires');
Menu[4] = new elem("/fr/successes/",'Témoignages');
Menu[5] = new elem("/fr/news/",'News & Informations');
Menu[6] = new elem("/fr/company/",'Société');

var SubMenu1 = new Array();
SubMenu1[0] = new elem("/fr/products/topmanufacturing/",'TopManufacturing');
SubMenu1[1] = new elem("/fr/products/plm/",'La Chaîne Numérique');

var SubMenu2 = new Array();
SubMenu2[0] = new elem("/fr/services/training/",'Formation');
SubMenu2[1] = new elem("/fr/services/support/",'Support');
SubMenu2[2] = new elem("/fr/services/adaptation/",'Adaptations');

var SubMenu5 = new Array();
SubMenu5[0] = new elem("/fr/news/pressreleases.asp",'Communiqués de presse');
SubMenu5[1] = new elem("/fr/news/pressroom.asp",'Espace presse');
SubMenu5[2] = new elem("/fr/news/shows.asp",'Salons');

var SubMenu6 = new Array();
SubMenu6[0] = new elem("/fr/company/profile.asp",'Profil');
SubMenu6[1] = new elem("/fr/company/careers.asp",'Emploi');
SubMenu6[2] = new elem("/fr/company/contactus.asp",'Contactez-nous');

with(menuStyle=new mm_style()){
onbgcolor="#006699";
align='center';
//onbgcolor="#4F8EB6";
oncolor="#ffffff";
//offbgcolor="#DCE9F0";
offbgcolor="#000000";
//offcolor="#515151";
offcolor="#ffffff";
bordercolor="#000000";
borderstyle="solid";
borderwidth=0;
separatorcolor="#CCCCCC";
//separatorcolor="#2D729D";
separatorsize="1";
padding=1;
fontsize="10";
fontstyle="normal";
fontfamily="Arial";
pagecolor="white";
pagebgcolor="#006699";
headercolor="#000000";
headerbgcolor="#ffffff";
//subimage="menu/arrow.gif";
subimagepadding="0";
overfilter="Fade(duration=0.2);";
outfilter="randomdissolve(duration=0.3)";
itemheight=20;
itemwidth=100;
//keepalive=1;
}

with(SubMenuStyle=new mm_style()){
onbgcolor="#006699";
align='center';
//onbgcolor="#4F8EB6";
oncolor="#000000";
//offbgcolor="#DCE9F0";
offbgcolor="#006699";
//offcolor="#515151";
offcolor="#ffffff";
bordercolor="#000000";
borderstyle="solid";
borderwidth=0;
separatorcolor="#CCCCCC";
//separatorcolor="#2D729D";
separatorsize="1";
padding=3;
fontsize="10";
fontstyle="normal";
fontfamily="Arial";
pagecolor="black";
pagebgcolor="#006699";
headercolor="#000000";
headerbgcolor="#ffffff";
//subimage="menu/arrow.gif";
subimagepadding="0";
overfilter="Fade(duration=0.5);";
outfilter="randomdissolve(duration=0.3)";
itemheight=20;
itemwidth=100;
//keepalive=1;
}

with(milonic=new menuname("Main Menu")){
style=menuStyle;
left=5;
top=85;
orientation="horizontal";
alwaysvisible=1;

for (var i = 0; i < Menu.length; i++){
   aI("text=" + Menu[i].title + ";url=javascript:mm_openUrl('" + Menu[i].url + "');showmenu=" + Menu[i].title + ";pagematch=" + Menu[i].url + ";status=" + Menu[i].title + ";");
}
}

with(milonic=new menuname(Menu[1].title)){
   style=SubMenuStyle;
   orientation="horizontal";
   left=5;
   //alwaysvisible=1;
   itemwidth=120;

for (var i = 0; i < SubMenu1.length; i++){
      aI("text=" + SubMenu1[i].title + ";url=javascript:mm_openUrl('" + SubMenu1[i].url + "');showmenu=" + SubMenu1[i].title + ";pagematch=" + SubMenu1[i].url + ";status=" + SubMenu1[i].title + ";");
      
}
}

with(milonic=new menuname(Menu[2].title)){
   style=SubMenuStyle;
   itemwidth=80;
   left=5;
   orientation="horizontal";
   //alwaysvisible=1;
for (var i = 0; i < SubMenu2.length; i++){
      aI("text=" + SubMenu2[i].title + ";url=javascript:mm_openUrl('" + SubMenu2[i].url + "');showmenu=" + SubMenu2[i].title + ";pagematch=" + SubMenu2[i].url + ";status=" + SubMenu2[i].title + ";");
}
}

with(milonic=new menuname(Menu[5].title)){
   style=SubMenuStyle;
   itemwidth=120;
   left=200;
   orientation="horizontal";
   //alwaysvisible=1;

for (var i = 0; i < SubMenu5.length; i++){
      aI("text=" + SubMenu5[i].title + ";url=javascript:mm_openUrl('" + SubMenu5[i].url + "');showmenu=" + SubMenu5[i].title + ";pagematch=" + SubMenu5[i].url + ";status=" + SubMenu5[i].title + ";");
}
}

with(milonic=new menuname(Menu[6].title)){
   style=SubMenuStyle;
   itemwidth=80;
   left=350;
   orientation="horizontal";
   //alwaysvisible=1;

for (var i = 0; i < SubMenu6.length; i++){
      aI("text=" + SubMenu6[i].title + ";url=javascript:mm_openUrl('" + SubMenu6[i].url + "');showmenu=" + SubMenu6[i].title + ";pagematch=" + SubMenu6[i].url + ";status=" + SubMenu6[i].title + ";");
}
}
drawMenus();

mm_getSelectionSequence();

//-->
</script>




Thanks for your help !
My licence number is The Domain name that this download has been created for is: http://www.topmanufacturing.info license number 196934

Rgds

David ARNOULT


Poster: kevin3442
Dated: Saturday February 26 2005 - 7:54:34 GMT

Hi David,

I see you've messed around with that mm_getSelectionSequence()function from a while ago. Did you get it working the way you want?

Anyway... regarding your desire to automatically open appropriate submenus on the next page to display the submenu/item responsible for the user getting to that page:

I assume you got the openUrl(), resetSubmenus() and autoOpenSubmenu() functions you're trying to use from this thread (or from this corresponding example). I don't know if I'd recommend using those functions. I wrote thos quite a whiel ago to help another user with some specific goals. Her goals shared some common aspects with your, but they were not the same. The functions would have to be re-written quite a bit.

Here's my suggestion: Instead of using those function, set up your menus as you normally would (e.g., in the aI() string, use url= instead of openUrl() to open the next page). Then, to have the correct submenus open automatically, all you have to do is load a file called openmenusbyurl.js into your page, right after where you load your menu_data.js file. I.e., where you load menu_data.js in your .html file, youd have another line to load openmenusbyurl.js, like so:
Code:
<script type="text/javascript" src="menu_data.js"></script>
<script type="text/javascript" src="openmenusbyurl.js"></script>

You can download openmenusbyurl.js by clicking this link, or by right-clicking the links and using "Save Target As..." (in IE). There isn't much documentation for the use of this file -- at least not that I've seen -- other than what you'll find in the comments at the top of the file if you open it in a text editor. As far as I know, the only mention of it came up in this thread. I have tried it, however, and it does work. As noted in the file's comments, the functionality requires Milonic Menus v5.62 or higher.

Here's the idea. if the page contains a Milonic Menu, and also loads the openmenusbyurl.js file, then the menu system will automatically open the submenus up to and including the submenu containing the item that got the user to the current page. For that to work, all you have to do is make sure that the page loads openmenusbyurl.js... no additional function calls or anything else is required.

There may be a little tweaking required here and there, because I don't think this functionality has been used very extensively. But I did a quick test and it seems to work well. I think you'll have better luck with that than with trying to use those functions I wrote for Tessa.

Cheers,

Kevin