Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

share|improve this question

4 Answers 4

up vote 0 down vote accepted

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 !

share|improve this answer
    
you are the man! Thank you! thats exactly what I needed. –  Tudor Jul 31 '12 at 15:38
    
Pleasure to be helpful :) –  J.Shah Aug 1 '12 at 9:31

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.

share|improve this answer
    
doesn't seem to work for me...I added this to my master page <head> <script type="text/javascript"> $().ready(function(){ $(".menu-horizontal").find("a").removeAttr("href"); }); </script> I am using the Publishing Infrastructure, is that the issue? –  Tudor Jul 26 '12 at 20:21
    
I forgot to mention, I tried replacing .menu-horizontal with a number of different tags including .s4-tn and I can't seem to get it working. –  Tudor Jul 26 '12 at 20:36
    
Is jquery included? If it isn't then the script won't do anything. –  PirateEric Jul 27 '12 at 0:00
    
Thanks! it works! however its not quite what I need, that basically disables the links that show up in the drop down under the main headings, is there a way to only disable the top links and not the ones in the dropdown? –  Tudor Jul 27 '12 at 16:20

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.

share|improve this answer
    
Thanks! it works! however its not quite what I need, that basically disables the links that show up in the drop down under the main headings, is there a way to only disable the top links and not the ones in the dropdown? –  Tudor Jul 27 '12 at 16:20

I think this will helps you to get your requirements:

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

share|improve this answer
    
awesome! thank you! that works perfectly, is there any way to activate just the first link? For example one of the web apps we have has a home link, can I have just that link active and not the rest? –  Tudor Jul 30 '12 at 17:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.