How to hide a ribbon in SharePoint 2010/2013/Online using Jquery

This post explains how to hide a SharePoint Ribbon in SP 2010/2013/ SP Online using jquery.
It is very simple jquery code to hide the ribbon.
For example say suppose you want to hide Add New Item Ribbon in a List called Contacts.
Here is how efficiently we can achieve this.

$(document).ready(function () {
    var currentPage = decodeURIComponent(window.location.href.replace(/\+/g, " "));
    if (currentPage.contains("Lists/Contacts")) {
      window.setTimeout(hideRibbon, 500);
    }
});
function hideRibbon() {
    $('span[id^="Ribbon.ListItem.New.NewListItem"]').hide()
    window.setTimeout(hideRibbon, 200);
}
Above simple jquery code does the trick. As you can see, if the url is lists/contacts, we are calling the method  hideRibbon with a delay. And in the hideRibbon method we are calling the same method again with a delay. which will keep hiding the ribbon.

Happy coding :)

Comments

Popular posts from this blog

SharePoint Online (O365) OAuth Authentication | Authorizing REST API calls against SharePoint Online Site | Get Access token from SharePoint Online | Set up OAuth for SharePoint Online Office 365

SharePoint 2013 REST API Reference

Simple Risk Assessment Matrix table with resultant risk calculation

Kendo UI (Core JavaScript) grid Server Paging, Server Sorting and Server Filtering with Dynamic SQL queries

Sharepoint- Using an Image From formatmap32x32.png in a Ribbon Control