PDA

View Full Version : Javascript drop-down menu link to html anchor



AMT
05-09-2005, 03:19 PM
Hi,

I've created a drop-down menu in Fireworks and need to link the menu links to a web page that I have already inserted html achors into. The menu code (sample) looks like this:

mm_menu_1112123030_0.addMenuItem("abcd","location='http://www.'");

I have about 10 menu items that need to be linked to 10 anchors listed on the same page.

Anyone have any ideas as to how this is achieved using js?

Cheers,
Adam

brandonH
05-09-2005, 08:44 PM
to go to an anchor ( <a> ) on the same page all you hve to do is for one, have anchors in the page and be sure to name them like so:
<a id=#anchor1></a>Anchor One
<a id=#anchor2></a>Anchor Two....ect

dont put the anchor text within the anchor, it will show up as a link. this way it shows up only as text but the anchor is still there.

and in the js all you have to do is assign the anchor id to window.location like so:
window.location='#anchor1';

it will jump to that anchor within the page.

AMT
05-10-2005, 08:57 AM
Fantastic, that seems to work nicely, thanks a lot for your help.