How to: Hide the Ribbon in SharePoint 2010
About the Ribbon in SharePoint 2010
The SharePoint 2010 ribbon provides a similar user experience as the Microsoft Office client products. The ribbon is a toolbar which appears on top of the page to provide the most commonly used tools, controls, and commands.
The ribbon hierarchy is organized as follows (see Figure 1 and Figure 2):
- Contextual Tag Group - A contextual tab enables you to provide a set of user interface (UI) controls within a certain context. For example, when you select a table in a document, a set of tabs is displayed to work with the table. When the
table is deselected, the contextual tabs are hidden. Contextual tabs with a similar context are organized in a contextual tab group so you can have more than one tab in a group. - Tabs – Tabs are used to organize groups of related controls. For example, an Insert tab displays controls that enable you to insert various objects into a document such as files, tables, images, and so forth.
- Groups – Groups are used to organize related controls such as the font group, styles group, document views group, and so forth.
- Controls – Buttons, dropdown controls, radio buttons, and other controls that enable you to perform a singular task from the ribbon.
The ribbon can have multiple tabs, tabs can have multiple groups, and group can have multiple controls.
Figure 1. Ribbon tabs and groups
![]()
Figure 2. Ribbon contextual tab group and controls
![]()
Hiding the Ribbon in SharePoint 2010
There are multiple ways to hide the ribbon in SharePoint 2010. For example:
- When publishing a website template (which you should use for public websites), there is a
Show/Hide ribbon option under the Site Actions drop-down menu. - By using the Security Trimmer control. The Security Trimmer control can be place around the ribbon in Master page to conditionally hide it based on user permissions. The following example shows that a user without manage permissions will not be able to
see the ribbon. The PermissionString attribute value can be changed based on the requirement.
<SharePoint:SPSecurityTrimmedControl PermissionsString="ManagePermissions" runat="server">
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle">
</div>
</SharePoint:SPSecurityTrimmedControl>
- By using custom code. JavaScript can be used to show or hide the ribbon in SharePoint 2010.
Creating JavaScript to Hide the Ribbon
In this section, you create a file that contains JavaScript code to show or hide the ribbon while loading a website and webpage. You then create an empty SharePoint 2010 project in Microsoft Visual Studio 2010 and then add the JavaScript file to it. Next,
you reference the JavaScript file in the Master page. Finally, you deploy and test the solution.
To create the JavaScript file
- Open Notepad.
- Add the following JavaScript code to the file and then save it as custom.js.
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);
}
_spBodyOnLoadFunctionNames.push("HideRibbon");
To create the Empty SharePoint 2010 Project
- Start Microsoft Visual Studio 2010.
- On the File menu, point to New, and then click
Project. - In the New Project dialog window, in the Installed Templates section, click
Visual C#, click SharePoint, and then click
2010. - Click Empty SharePoint Project from the project items.
- In the Name box, type RibbonDemo and then click
OK. - In the SharePoint Customization Wizard, type the local website that you want to use for this exercise (such as
http://localhost/SampleWebSite). - For the trust level, select Deploy as a farm solution and then click
Finish. - In Solution Explorer, right-click the RibbonDemo project name, point to
Add, and then click Existing Item. - Navigate to the JavaScript file you created previously (custom.js) and then click
Add. - Open the SharePoint 2010 Designer to the website you specified when you created the Visual Studio project.
- Open the website Master page; add the following code, and then save it.
<SharePoint:ScriptLink language="javascript" name="RibbonDemo/jquery-1.6.4.min.js" runat="server"/>
<SharePoint:ScriptLink language="javascript" name="RibbonDemo/custom.js" runat="server"/>
To deploy and test the solution
- In Solution Explorer, right-click the RibbonDemo project name, and then click
Deploy. - Start Internet Explorer and browse to the website specified previously. The ribbon is hidden when the webpage loads.
This post discussed the SharePoint 2010 ribbon and how to hide it by using JavaScript. You can find more information about the topics discussed here at the following locations.
How to: Hide the Ribbon in SharePoint 2010的更多相关文章
- Custom Ribbon in SharePoint 2010 & which not wrok when migrate from 2010 to 2013
博客地址 http://blog.csdn.net/foxdave 1. First of all, let me show you the ribbon modal in our project w ...
- SharePoint 2010 Ribbon with wrong style in Chrome and Safari
When we add custom ribbon to SharePoint 2010, it may display well in IE but not in Chrome and Safari ...
- Sharepoint 2010 根据用户权限隐藏Ribbon菜单(利用css)
本文介绍的是根据用户权限隐藏整个Ribbon菜单项. 操作环境:Windows Server 2008 r2+ SharePoint 2010 1.关于SharePoint 权限详细请参考:http ...
- [转]SharePoint 2010 Download as Zip File Custom Ribbon Action
在SharePoint 2010文档库中,结合单选框,在Ribbon中提供了批量处理文档的功能,比如,批量删除.批量签出.批量签入等,但是,很遗憾,没有提供批量下载,默认的只能一个个下载,当选择多个文 ...
- sharepoint 2010 显示和隐藏Ribbon区域条
在sharepoint 2010的页面中,我们在页面的最上方,有一条深灰色的Ribbon工具栏,如下图,这里可以通过下面的脚本,做一些脚本,来控制它的隐藏和显示. 最后把这些脚本,放在v4.maste ...
- sharepoint 2010 怎样在Ribbon区加入功能button
继续前面的一篇博客,sharepoint 2010 怎样在列表中加入功能菜单操作项.这次主要是记录下,在Ribbon区域加入功能button.比如加入收藏button.例如以下图所看到的: 1. 还是 ...
- SharePoint 2010 Modal Dialog
SharePoint 2010 Modal Dialog Tweet Modal dialog play very important role to improve the user exper ...
- Upgrade from SharePoint 2010 to SharePoint 2016
[转]http://nikcharlebois.com/upgrade-from-sharepoint-2010-to-sharepoint-2016/ In this blog, I will go ...
- 使用SharePoint 2010 母版页
SharePoint 2010母版页所用的还是ASP.NET 2.0中的技术.通过该功能,实现了页面框架布局与实际内容的分离.虽然在本质上自定义母版页的过程和以前版本的SharePoint大致相同,但 ...
随机推荐
- 九度OJ 1402 特殊的数 -- 位操作
题目地址:http://ac.jobdu.com/problem.php?pid=1402 题目描述: 现在有n个数,其中有一些出现了一次,一些出现了两次,一些出现了很多次.现在要求你找出那些只出现一 ...
- Android-ViewPagerIndicator-master 、Android-PullToRefresh 学习篇
最近在学习android,然后看到了很多有用的开源库.其中一个就是Android-ViewPagerIndicator :. 这是与ViewPager兼容的一个分页指示器库.分页指示器(Friends ...
- c#拖放
AllowDrop DragEnter: if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Cop ...
- Git 安装与使用(一)
一.简介 1.集中式版本控制系统(CVS):Svn * 版本库是集中存放在中央服务器中的,客户端需要先从中央服务器取得最新的版本,然后再干活,活干完后,再把自己的代码推送给中央服务器. ...
- UILocalNotification本地通知
// 执行通知一定要退出应用或挂起应用(进入后台)才能收到通知. 1.在iOS8及其以后版本中使用本地消息需要先获得用户的许可,否则无法成功注册本地消息.因此,我们将询问用户许可的代码片段添加到了ap ...
- codevs 1743 反转卡片
题目描述 Description [dzy493941464|yywyzdzr原创] 小A将N张卡片整齐地排成一排,其中每张卡片上写了1~N的一个整数,每张卡片上的数各不相同. 比如下图是N=5的一种 ...
- 17款code review工具
本文是码农网原创翻译,转载请看清文末的转载要求,谢谢合作! 好的代码审查器可以大大地帮助程序员提高代码质量,减少错误几率. 虽然现在市场上有许多可用的代码审查工具,但如何挑选也是一个艰巨的任务.在咨询 ...
- POJ - 2711 Leapin' Lizards
题目大意: 在一个网格地图中有一些高度不同的石柱,一些石柱上站着一些蜥蜴,你的任务是让尽量多的蜥蜴逃到边界外. 每行每列中相邻石柱的距离为1,蜥蜴的跳跃距离是d,即蜥蜴可以跳到平面距离不超过d的任何一 ...
- Integer.valueOf与Integer.parseInt的小疑惑
参考博客: http://www.importnew.com/9162.html 测试代码如下: public class Main { /** * 备注:结果跟你的JDK版本有关系: * * 我的是 ...
- 项目管理系统 SQL2005数据库查询CPU100%问题研究
[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/4595084.html] 在项目管理系统中出现查询工程明细出现CPU100%卡死症状: 1.打 ...