我们在开发Sharepoint 2013 的时候,常常需要隐藏Ribbon,那个Ribbon是属于Office的特征,但是我们做门户的时候,大家都不希望看见到它,但是我们又离不开它,以管理的身份进行设计列表或文档库的时候,必须需要它,没有它的话,很多功能就无法实现了。基于以上背景需求,我们可以利用母版页里面的SPSecurityTrimmedControl控件,它的用途就是识别当前用户在网站的角色,有了它就比较好办了,我们找到Ribbon 的样式class,在自己的样式表中,我们隐藏掉它,当是管理员角色登录的时候,我们就显示出Ribbon,如下代码:

        <!--MS:<SharePoint:SPSecurityTrimmedControl runat="server" AuthenticationRestrictions="AuthenticatedUsersOnly" Permissions="AddAndCustomizePages">-->
<script type="text/javascript">
document.getElementById("s4-ribbonrow").style.display = "block";
document.getElementById("suiteBar").style.display = "block"; </script>
<!--ME:</SharePoint:SPSecurityTrimmedControl>-->

如此简单就解决了,其实还有好几个办法也能实现。

  Javascript的实现方案:

function ShowRibbon() {

   $("#s4-ribbonrow").show();

   $("#s4-workspace").height($(document).height() - $("#s4-ribbonrow").height() * );

}

function HideRibbon() {

   $("#s4-ribbonrow").hide();

   var newHeight = $(document).height();

   if ($.browser.msie) {newHeight = newHeight - ; }

      $("#s4-workspace").height(newHeight);

}

_spBodyOnLoadFunctionNames.push("HideRibbon");

封装好JS文件,然后用VS开发工具,打包成解决方案包,直接部署就OK了。

  

最新文章

  1. Singleton(单例模式)
  2. python远程连接paramiko 模块和堡垒机实现
  3. Springfox Reference Documentation
  4. Oracle的数据恢复——Flashback用法汇总
  5. [C语言](二)01 获取Windows图形构件大小信息
  6. Jabber/XMPP协议与架构
  7. git 基础命令
  8. CSS 布局Float 【2】
  9. [LeetCode 114] - 将树平面化为链表(Flatten Binary Tree to Linked List)
  10. 动态绑定ReportViewer控件之经验总结
  11. 实现table中checkbox复选框、以及判断checked是否被选中、js操作checkedbox选中
  12. java实现https请求
  13. Go:学习笔记兼吐槽(1)
  14. 潭州课堂25班:Ph201805201 tornado 项目 第九课 深入应用 WebSockets(课堂笔记)
  15. 深入理解JVM(七)JVM类加载机制
  16. SVN与资源库同步后动作的字母意义
  17. Think Python 2E中译本 _site
  18. 国内混合APP开发技术选型
  19. laravel 前后端分离 token
  20. GIT 分布式版本控制系统的简单使用介绍

热门文章

  1. [转载]Java导出Excel
  2. MVC和EF中的 Model First 和 Code First
  3. UITextField点击选中文字
  4. The program environment for cypress cy8ckit-002
  5. 【SQL查询】分区查询Over
  6. Caused by: java.lang.AbstractMethodError: org.hibernate.validator.internal.engine.ConfigurationImpl
  7. 怎么样在python 3.6里安装tensorflow?
  8. js `` 手机不支持
  9. Swift 发送邮件和发短信
  10. swift实现label换行