/    Sign up×
Community /Pin to ProfileBookmark

pop-up menus woe’s

OK, so for now I have this all working, but there’s a problem with the javascript that I still don’t like. I used Dreamweaver MX, and here’s what I did to make my pop-up menu:

For the main links, I just made rollover images that come standard with Dreamweaver. Then for the menus that pop out of these menu links I just made them into layers and made them invisible. So I can hide or show them by using these functions:

[B]function show(object)[/B] { if (document.layers && document.layers[object] != null) document.layers[object].visibility = ‘visible’; else if (document.all) document.all[object].style.visibility = ‘visible’; }

[B]function hide(object)[/B] { if (document.layers && document.layers[object] != null) document.layers[object].visibility = ‘hidden’; else if (document.all) document.all[object].style.visibility = ‘hidden’; }

OK, now for the problem. I wanted to make it so that when I roll on to a sub-menu, it would keep that main menu link highlighted so you know which link this sub-menu is coming from. Seems simple enough.

So I just used the MM_swapImage() function that comes with Dreamweaver:
[B]function MM_swapImage()[/B] { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

So I added this code to that submenu layer:
onMouseOver=”MM_swapImage(‘main_link’,”,’images/mainlink_on.gif’,1);”

onMouseOut=”MM_swapImage(‘main_link’,”,’images/mainlink_off.gif’,1);”

Now, for some reason, this messes with the rest of my code that uses the MM_swapImage function. I guess there’s something wrong with using it on two objects at the same time. So I made my own separate function to handle changing the main_link picture.

Is there any way I can use Dreamweavers script to do this?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @mwmundy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...