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: Wednesday July 18 2012 - 06:07:46
IMPROVED:
Poster: nstohler __at__ madtoaster.com
Dated: Thursday January 31 2002 - 8:39:25 GMT
Hello
The menu is great! One that isn't perfect in my opinion in the current release is the "last menu item clicked"-feature, which uses cookies to hilight the last clicked item. This doesnt work, if the user comes directly to a page (without clicking on an item) or uses the back-button.
So, I did some coding, and came up with the following solution:
===================
menu_array.js :
----------------------------------
[...]
//////////////////////////////////
// Editable properties END here //
//////////////////////////////////
//-------------------------------------------
// code inserted by nicolas stohler
var mpUrl2Nr = new Object();
var nNr = 0;
for( var i in menus )
{
var j = 23; // url item
while( typeof menus[i][j] != "undefined" )
{
var s = j;
if( menus[i][j].indexOf("show-menu") != -1 ){ s ; }
if( menus[i][s].length > 0 ){ mpUrl2Nr[menus[i][s]] = "smenu=" nNr "#"; }
nNr ;
j =5;
}
}
for( var i in mpUrl2Nr )
{
if( document.location.href.indexOf(i) != -1 )
{
var sCurPage = mpUrl2Nr[i];
break;
}
}
// end of code insert
//-------------------------------------------
dumpmenus() // This must be the last line in this file
===================
mmenu.js :
----------------------------------
a)
replace "tc=_d.cookie;" with "tc=GetPageId();"
b) add the function to the end of the file:
function GetPageId()
{return ( typeof sCurPage != "undefined" ? sCurPage : "" ) }
Ok, I hope you can include this in your next release (with an option wheter to use the cookie or the new feature...)
There's a little BUG i noticed: if a menu item that owns subitems gets hilighted, the hilighting works, but after I move the mouse over the item and out again, the hilighting is completely gone.
that's all
Nicolas