How To Add Menu Action On Your Office 365 SharePoint Sites

In this blog, we will see how to add a menu option in Office 365 SharePoint site. We can add the menu option on the top right corner of the Settings page or as a navigation on the site’s  Setting link.

Let’s see how we can add the menu action using script.

  • Open your site
  • Go to Edit Page by clicking on the Settings gear in the top-right corner

    SharePoint

  • Click on Check Out

    SharePoint
  • You will see the Edit page of the site
  • Click on “INSERT” under Media and Content and add "Script Editor".

    SharePoint

  • Open the Script Editor and paste the code given below. 
  • SharePoint

  • Code Snippet
    1. <script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>  
    2. <script language="javascript" type="text/javascript">  
    3.     $(document).ready(function() {  
    4.         SP.SOD.executeFunc('sp.js''SP.ClientContext', AddSettingsMenuAction);  
    5.     });  
    6.   
    7.     function AddSettingsMenuAction() {  
    8.         //Read the web  
    9.         var clientContext = new SP.ClientContext();  
    10.         var oWeb = clientContext.get_web();  
    11.         //Add the new custom action  
    12.         var collMenuAction = oWeb.get_userCustomActions();  
    13.         var menuAction = collMenuAction.add();  
    14.         menuAction.set_location('Microsoft.SharePoint.StandardMenu');  
    15.         menuAction.set_sequence(101);  
    16.         menuAction.set_group('SiteActions');  
    17.         menuAction.set_title("My Home");  
    18.         menuAction.set_url("https://sharepointworldbymanpreet.wordpress.com/");  
    19.         menuAction.update();  
    20.         //Load the group details and execute  
    21.         clientContext.load(collMenuAction);  
    22.         clientContext.executeQueryAsync(ScriptSuccess, ScriptFailure);  
    23.     }  
    24.     //Log Success Details  
    25.     function ScriptSuccess() {  
    26.         console.log("Menu Added");  
    27.     }  
    28.     //Log Failure Details  
    29.     function ScriptFailure() {  
    30.         console.log(args.get_message());  
    31.     }  
    32. </script>  

  • Click on OK.

    SharePoint

  • You will see a “My Home” menu button attached to your menu option.

Using this script, you can add the menu items of your choice for all the users who will access the SharePoint sites.

Keep reading & keep learning!!

Ebook Download
View all
Learn
View all