Monday, 25 June 2012

Hide and Show the SharePoint 2010 Ribbon

If your SharePoint site users are fed up with Ribbon, because most of times SharePoint 2010 Ribbon takes space at top of site.

Ribbon is mostly used by Administrator or Editors, those are very few in count as compare to readers.
Users who have read permission they don't require Ribbon most of times

Following code will Show and Hide the SharePoint 2010 site Ribbon on clicking on buttons. You can write your own code that will automatically Show/Hide the Ribbon.

You can add following code in Master page.

Code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function ShowRibbon() {
$('#s4-ribbonrow').show();
$('#s4-workspace').height($(document).height() - $('#s4-ribbonrow').height() * 2);
}
function HideRibbon() {
$('#s4-ribbonrow').hide();
var newHeight = $(document).height();
if ($.browser.msie) { newHeight = newHeight - 3; }
$('#s4-workspace').height(newHeight);
}
</script>
<input id="Button1" type="button" value="ShowRibbon" onclick="ShowRibbon()" />
<input id="Button12" type="button" value="HideRibbon" onclick="HideRibbon()" />


 Goto the browser and refresh.

Once you click on "ShowRibbon" option.


Once you click on "HideRibbon" option.

No comments:

Post a Comment