locked
Disable second level global navigation RRS feed

  • Question

  • Hi,

    We have a requirement where we want to disable second level menu in global navigation.

    Business Site1

            |

           \/

    Business Site 2 --> Business Site 3

    So the currently, the Business Site 2 is clickable. Our requirement is that Business Site 2 should not be clickable, only Business Site 1 and business Site 3 should be clickable.

    Or on click of business Site 2 , business Site 3 should open.

    The setting for global navigation is to inherit from parent site and Show subsite is set to true. So there are no explicit nodes created. All the nodes are for Subsites. In this way when I try to change the settings programmatically, the count of nodes is 0 as there are no nodes available.

    Please help.

    Regards,

    Vijay

    Tuesday, April 22, 2014 9:04 AM

Answers

  • Hi Victoria,

    Thanks a lot for the above script. That has worked for me and I am able to disable only the second level navigation. Just one correction is needed in the above script. "static" class should be replaced by "dynamic". So the final script would look like this:

    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
      $
    (function () {
      $
    (".s4-tn li.dynamic.dynamic-children > a").attr("href","#");
    });</script>

    The above script will work perfect. I am marking this as answer. Thanks again.

    Just one more question. Will that above script be limited to global navigation only. Won't that affect any other links on the Site.?

    Regards,

    Vijay

    • Marked as answer by VJSCloud Thursday, April 24, 2014 8:39 AM
    Thursday, April 24, 2014 8:39 AM

All replies

  • Hi Vijay,

    According to your description, my understanding is that you want to disable the second navigation link in Global Navigation.

    I recommend to create an JS file with the code below and then upload it to SharePoint, then refer the JS file in Master Page.

    Here is the code:

    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    
    <script type="text/javascript">
    
      $(function () {
    
         $(".s4-tn li.static.dynamic-children").each(function(i){ 
    
         $(this).find("a").attr("href","#");
    
                    });
    
    });
    
    </script>

    Or you can add the code above to the master page directly.

    Best regards.

    Thanks


    Victoria Xia
    TechNet Community Support


    Wednesday, April 23, 2014 3:45 AM
  • Hi Victoria,

    Thanks for the script.

    The script is indeed working however, it is disabling all the three level links of global navigation.

    As an ex. from my above description, it is disabling Business Site1, Business Site 2 and Business Site 3 whereas my requirement is to disable Business Site 2 only

    Thanks

    Vijay

    Thursday, April 24, 2014 5:28 AM
  • Hi Vijay,

    You can use the code below to only disable the second level global navigation:

    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
      $(function () {
      $(".s4-tn li.static.dynamic-children > a").attr("href","#");
    });</script>

    Best regards.

    Thanks


    Victoria Xia
    TechNet Community Support

    Thursday, April 24, 2014 5:39 AM
  • Hi Victoria,

    Thanks a lot for the above script. That has worked for me and I am able to disable only the second level navigation. Just one correction is needed in the above script. "static" class should be replaced by "dynamic". So the final script would look like this:

    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
      $
    (function () {
      $
    (".s4-tn li.dynamic.dynamic-children > a").attr("href","#");
    });</script>

    The above script will work perfect. I am marking this as answer. Thanks again.

    Just one more question. Will that above script be limited to global navigation only. Won't that affect any other links on the Site.?

    Regards,

    Vijay

    • Marked as answer by VJSCloud Thursday, April 24, 2014 8:39 AM
    Thursday, April 24, 2014 8:39 AM
  • Hi Vijay,

    I tested the code in my second post in my environment and the code worked fine.

    And if the code is added to mater page, all the second global navigation will be disabled in the sites which are inherited from the master page.

    Best regards.

    Thanks


    Victoria Xia
    TechNet Community Support

    Thursday, April 24, 2014 9:21 AM
  • Hi Victoria,

    Thanks a lot for the help.

    The code has worked properly in my Development environment. But our application also works in iPad. The OOTB second level links open on mouseover event.

    But the issue is there is no mouseover event in case of iPad. We need to open the second level link on some event (don't know right now) and the second level link should not be clickable and the third level link should open on some event (don't know right now) and the third level link should be clickable.

    Need your help on above requirement.

    Thanks & Regards,

    Vijay

    Monday, April 28, 2014 5:42 AM