PDA

View Full Version : AnyLink DD Menu tweak?



Zaph
05-10-2005, 08:07 PM
Hi,

I'm using the AnyLink DD Menu http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm and was wondering if it would be possible to set it up so that even though I'm using the script in an external .js file it does not show the current page in the the menu.

That is to say if a user is on the "news" page, that link is removed from the drop down list.

I can't think of anyway of doing it, and I'm starting to think it's not possible, but clarification would be nice either way!

Thanks,
Martyn.

jscheuer1
05-11-2005, 10:18 AM
There is probably a 'cleaner' way to do it but, this works:

Put this script in the head of each page displaying the menu:

<script type="text/javascript">
function hideItem(item){
eval(item+'='+item+'.replace(/a href/,\'a style="display:none" href\')')
}
</script>
You could probably just include its function at the beginning of your external script like so:

function hideItem(item){
eval(item+'='+item+'.replace(/a href/,\'a style="display:none" href\')')
}

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a>'
menu1[1]='<a href="http://www.freewarejava.com">Freewarejava.com</a>'
Then on each page that this menu navigates to use this in the body tag:

<body onload="hideItem('menu1[0]')">For menu1[0], just substitute the the menu#[#] you want excluded on that page.

Zaph
05-12-2005, 10:52 PM
Thanks for the info.

My intranet has now gone live, so this will have to wait until I finish v2.0, as it will involve changing each and every page on the site (current count around 300!), and I really a) dont have the spare time and, b) cant be bothered right now!

Still, it looks good, and it was basically what I had in my original version, before I placed the main script in an external.js file.

Martyn.