Moss 2013 study series --- hide RIBBON

Source: Internet
Author: User

When developing SharePoint 2013, we often need to hide the ribbon, which is a feature of the office, but we do not want to see it when making a portal, but we can't do without it. When designing a list or document library as a management identity, we must use it. Without it, many functions cannot be implemented. Based on the preceding background requirements, we can use the spsecuritytrimmedcontrol control on the master page to identify the role of the current user on the website. It is easier to use it, we find the ribbon style class. In our style sheet, we hide it. When the Administrator is logged on, we will display the ribbon, as shown in the following code:

 

        <!--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>-->

 

There are several ways to solve this problem.

Javascript Implementation Scheme:

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");


Encapsulate the JS file, use the vs development tool, package it into a solution package, and directly deploy it.

 

 

 

 

 

 

 

 

 

 

 

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.