Back To Start Of Archive
Taken From The Forum: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:23
Fix for submenu display position?
Poster: Ruth
Dated: Wednesday July 23 2003 - 22:17:39 BST
This might be a little involved since I don't have a site yet to show what I am trying to do. I made a little menu gif, and set it as a draggable. When you mouse over it opens a 'submenu' which is actually the main category menu. I set the submenu offsets so that when you mouseover the little menu gif the 'main category menu opens just below it so it looks like a sliding type menu. The problem is, now ALL the submenus use those same offsets and I need them to have different ones, is there a way to do that?
Ruth
Poster: Ruth
Dated: Wednesday July 23 2003 - 23:32:05 BST
I got my own answer so thought I'd post it. Just put in another menu array, without the line about leaving intact only once, for the other submenus.
Ruth
Poster: Ruth
Dated: Sunday July 27 2003 - 0:25:49 BST
Thought I'd better post that that doesn't work and nothing I've tried works ......
Poster: kevin3442
Dated: Saturday August 2 2003 - 10:17:31 BST
Sorry Ruth... I went and asked for a URL when your first post clearly said tat you didn't have a site yet.
If I understand you correctly, you want to specify offsets for each submenu individually, rather than use the global offsets that are typically found at the top of the array file (suboffset_top and suboffset_left).
I'm assuming that your dragable menu gif is also a Milonic menu set to be Always Visible and made dragable, like the sample dragable menu on the Milonic site. If that's the case, then the offset problem should be relatively easy. A little known function of the Top and Left elements of a menu array (2nd and 3rd elements repectively) is that they can be used to specify offsets for each menu. Usually, when Top and Left are used, they are set to numeric values to set an absolute position. In most implementations, these two elements are not set in submenus, so that the system will automatically determine the opening position based on the calling menu item's position. However, you can specify an offset string in the Top and Left elements, like so.
"offset=5"
It must be a string, so the quotes are important; you could use a string variable as well. The value (5 in the example above) indicates the number of pixels to offset the menu from where it would normally open if the Top or Left element was left blank. You can use positve or negative values.
Hope that made sense (it's late here) and that it helps.
Kevin
thanks, that works, another ?
Poster: Ruth
Dated: Wednesday August 6 2003 - 5:54:33 BST
This time I put up a test page so it could be seen, though some images are not up there. Anyway, I fixed it so the first submenu that comes off of a 'backimage' has to be clicked to open, then all the other menus off that one will open on mouseover. But, how do I fix it so that that first submenu you open on click stays open until you click it closed and not just until you stop doing mouseover on the other links? Is that possible? It's like once it's opened I want it to stay opened unless you actually click that particular menu closed. Thanks....
LINK REMOVED
Ruth
Poster: Hergio
Dated: Wednesday August 6 2003 - 14:55:57 BST
Using the functionality of the menu alone, I doubt it is possible. But heres how you'd do it will alittle javascript trickery....hopefully you are tech savvy enough to follow what I am saying.
Basically put your menu inside of a table consisting of one column, two rows. The top row will say MENU in it, and the second row will have its style attribute called display set to NONE. This will give you what looks like your menu when you first visit the page. Place your menu code inside of this second table cell thats initially hidden. Then put an ONCLICK event handler on the MENU row that says when clicked, change the display style of the menu's cell to block if its hidden, or hidden if its visible.
Code:
<table>
<tr><td onClick='toggleMenuCell();'>MENU</td></tr>
<tr>
<td id='tdMenu' style='display:none;'>
<!-- PUT YOUR MENU HERE -->
</td>
</tr>
</table>
<tr><td onClick='toggleMenuCell();'>MENU</td></tr>
<tr>
<td id='tdMenu' style='display:none;'>
<!-- PUT YOUR MENU HERE -->
</td>
</tr>
</table>
Now have javascript code that says:
Code:
function toggleMenuCell()
{
menuCell = document.all["tdMenu"];
if( menuCell.style.display == "none" )
{
menuCell.style.display = "block";
}else{
menuCell.style.display = "none";
}
}
{
menuCell = document.all["tdMenu"];
if( menuCell.style.display == "none" )
{
menuCell.style.display = "block";
}else{
menuCell.style.display = "none";
}
}
This SHOULD help solve your problem. Let me know if it works!
P.S. The javascript function above will only work with Internet Explorer, due to my use of the 'document.all[]' call I made. TO make this browser independant, you'll have to do alittle additional code. You should be able to find info on that on the net without me having to explain it here.
Poster: Ruth
Dated: Wednesday August 6 2003 - 21:51:07 BST
Thanks, Dave. I will mess with it, and no I'm not tech savvy. My method is to 'play' I guess the term would be. However, if the menu will take an onclick event to open it, isn't there a way to put in an onclick to close it also? Again, I really don't understand much how code works, I can copy and paste etc. but...for example, in this instance to get the 1st submenu to open onclick I initiated the code in the main menu which has 'plainstyle' as properties, but the 1st submenu that opens has a different property array, and I noticed at the end of the menus properties it has a place that says 'miscellaneous menu properties, could a javascript code or something be put in there which would be for an onClick close menu? And if yes, I'd need some help with how to do the coding, since I don't know how to write codes. Sorry, if the question seems rambling, but without knowing about the coding it's hard to figure out how to phrase the question so the more knowledgeable know what is being asked.
Ruth