Question

Is there any way I can make the top links on the nav bar inactive? Basically I have created sites under the root such as

Company Info
HR
Team 1
Team 2....

and under each of those there are sub sites which show up in the drop down.

I want the top links

Company Info
HR
Team 1
Team 2....

to be inactive. So if a user clicks them they dont navigate to the site, can this be done? I would be ok with changing the link so it would just link back to the home page, but where would I change that?

Thanks for any help!

Was it helpful?

Solution

Yes, you can do it. Use this:

$("body #s4-topheader2. ul li ul li.static > a").each(function(index) {

if(index!=2)
{

    $(this).attr("href","javascript:void(0);");
}

});

Cheers !

OTHER TIPS

I tested this line of jQuery against a SP2010 page running the v4.master

$().ready(function(){
 $(".menu-horizontal").find("a").removeAttr("href");
});

Put this right on the master page, or hook it up to a CustomAction to load this all over the site.

Be aware that certain features in SharePoint(like Publishing Infrastructure, for example) alter the DOM a little so you may have to F12 this if it doesn't work at first.

I was having same requirement. and this works for me.

$(document).ready(function() {

     $("body #s4-topheader2. ul li ul li a").attr("href","javascript:void(0);");
});

May be it helps you.

Don't forget to include JQuery in your master page.

Would putting the following in the header work?

<script type="text/javascript">
$("body #TopNavigationMenuV4. ul li ul li.static > a").each(function(index) {
if(index!=2) {
$(this).attr("href","javascript:void(0);");
}
});
</script>

I couldn't get this working at all...

I think this will helps you to get your requirements:

$("body #s4-topheader2. ul li ul li.static > a").attr("href","javascript:void(0);");
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top