SharePoint - Remove the ribbon tabs from a list item

This post will tell you how to remove the tabs on the ribbon when you look at a list item in classic view


Add this code into the display form in SharePoint designer

<script type="text/javascript">// 
function ResetRibbon() {
try {
var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
SelectRibbonTab(&quot;Ribbon.Read&quot;, true);
ribbon.removeChild(&apos;Ribbon.ListForm.Display&apos;);
ribbon.removeChild(&apos;Ribbon.ListForm.Edit&apos;);
} catch (e)
{ }
}

SP.SOD.executeOrDelayUntilScriptLoaded(function () {
try
{
var pm = SP.Ribbon.PageManager.get_instance();

pm.add_ribbonInited(function () {
ResetRibbon();
});

var ribbon = null;
try {
ribbon = pm.get_ribbon();
}
catch (e) { }

if (!ribbon) {
if (typeof (_ribbonStartInit) == &quot;function&quot;)
_ribbonStartInit(_ribbon.initialTabId, false, null);
}
else {
ResetRibbon();
}
},
&quot;sp.ribbon.js&quot;);
}catch(e)
{}
// </script>

<script type="text/javascript">
function ResetRibbon() {
try {
var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
SelectRibbonTab(&quot;Ribbon.Read&quot;, true);
ribbon.removeChild(&quot;Ribbon.ListForm.Display&quot;);
ribbon.removeChild(&quot;Ribbon.ListForm.Edit&quot;);
} catch (e)
{ }
}

SP.SOD.executeOrDelayUntilScriptLoaded(function () {
try {
var pm = SP.Ribbon.PageManager.get_instance();

pm.add_ribbonInited(function () {
ResetRibbon();
});

var ribbon = null;
try {
ribbon = pm.get_ribbon();
}
catch (e) { }

if (!ribbon) {
if (typeof (_ribbonStartInit) == &quot;function&quot;)
_ribbonStartInit(_ribbon.initialTabId, false, null);
}
else {
ResetRibbon();
}
} catch (e)
{ }
}, &quot;sp.ribbon.js&quot;);

</script>




If you want to keep the display tab up (for workflow approvals, remove this line:
ribbon.removeChild(&apos;Ribbon.ListForm.Display&apos;);

-------------------------------------------------------------------------------------
Another way would be to remove it using CSS

<style>
#suiteBar, #ms-designer-ribbon {
display: none;
}
</style>
--------------------------------------------------------------------------------------

Source: https://social.technet.microsoft.com/Forums/office/en-US/93780f44-80ff-46b5-a80f-bc4ef09e4113/how-to-remove-ribbon-and-sites-bar-on-a-particular-site-page-sharepoint-365?forum=sharepointgeneral

Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.