Category Archives: SuitBar

Hide Ribbon and SuitBar of SharePoint 2013 for a specifique Zone – Using JavaScript and C#

One way to hide Ribbon and SuitBar of SharePoint 2013 for a specific zone, like Internet for example – you can use Javascript + Css and run it in a UserControl.

1 – Create a simple UserControl on your solution and add it on your MasterPage.

In ASCX file of your UserControl add the following code:

<script type="text/javascript">
    function hideRibbon(){
        document.getElementById("s4-ribbonrow").style.display = "none !important";
        document.getElementById("suiteBar").style.display = "none !important";
    }
</script>

On code behind of UserControl,  you go execute the javascript function, using the following code:

Example to hide in Internet zone

using Microsoft.SharePoint.Administration;
...

protected void Page_Load(object sender, EventArgs e)
{
 if (SPContext.Current.Site.Zone == SPUrlZone.Internet)
 {
 Page.ClientScript.RegisterStartupScript(this.GetType(),"","hideRibbon();",true);
 }
}