PDA

View Full Version : Anylink Dropdown Menu & JS img change of parent links



Robin
07-11-2005, 06:56 PM
Hi,

I want to use this fabulous Anylink script but am running into a little problem combining Anylink with the JS code which Dreamweaver MX produces when you insert a graphical Navigation Bar. I will post Dreamweaver's JS code below. Maybe someone who is more into JS than I am can tell me what's to modify.

Now the problem description: The "onMouseOut" event doesn't seem to trigger anymore after inserting the Anylink JS function calls.

Example of Parent Link with Dreamweaver's JS code but without Anylink code:

<a href="../showrooms/index.html" onClick="MM_nbGroup('down','group1','_0_showrooms','',1);" onMouseOver="MM_nbGroup('over','_0_showrooms','/images/navi/0_showrooms_h.gif','',1);" onMouseOut="MM_nbGroup('out');"><img src="/images/navi/0_showrooms_l.gif" name="_0_showrooms" width="115" height="24" border="0" /></a> ==> mouseover and mouseout work fine as always

Example of parent link with Dreamweaver's JS code and Anylink code:

<a href="../showrooms/index.html" onClick="MM_nbGroup('down','group1','_0_showrooms','',1); return clickreturnvalue();" onMouseOver="MM_nbGroup('over','_0_showrooms','/images/navi/0_showrooms_h.gif','',1); dropdownmenu(this, event, 'anylink_default_navi_sub1_showrooms');" onMouseOut="MM_nbGroup('out');"><img src="/images/navi/0_showrooms_l.gif" name="_0_showrooms" width="115" height="24" border="0" /></a> ==> mouseover works fine, anylink works fine. But on mouse-out the image won't change back. No JS error shows up.

Now this is the JS code of the image changery:

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) {
img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr)
for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
} }
}

So anyone can tell what's to do in order to get that all running correctly? :-) Thanx a lot in advance!
Robin

Robin
07-11-2005, 07:16 PM
Oh. I just tried around and maybe found a solution:
I added MM_nbGroup('out'); in the Anylink function delayhidemenu() like this:


function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay);
MM_nbGroup('out');
}
So the parent link image changes back when mouse moves out.
Would be better if the image would change back after the delay but as first shoot it is ok. :-)
If someone finds a cooler solution I would appreciate to know about. :-) Thanx.
Robin