1

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!

2

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 !

  • 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
0

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.

  • 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. – Eric Alexander 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
0

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.

  • 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
0

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...

  • where do you put this code, in a script web part on the page? – raj Oct 30 '17 at 11:58
0

I think this will helps you to get your requirements:

$("body #s4-topheader2. ul li ul li.static > a").attr("href","javascript:void(0);");
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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