As you know, SharePoint 2013 sites have a new look and feel aligned with modern UI interfaces. For instance, the new Team Site template includes Live Tiles in the home page. Additionally, every SharePoint 2013 site has new navigation top bars designed to simplify how a SharePoint user can access common places and functions like his personal Skydrive, his social content areas, etc. In this article I will show how you can easily customize these navigation bars by using JavaScript:
-
First, you need to access SharePoint 2013 either in a CloudShare environment or in Office 365. In my case, I will show you how to customize top navigation bars in SharePoint Online in Office 365.
-
Create a new Web Part page in the site choosing one of the available templates.
-
Once the Web Parts page is created, add a Script Editor to one of the Web Parts zones available in the page.
-
Click the “EDIT SNIPPET” configuration option in the Web Part.
-
In the popup window that is shown, just add the following JavaScript code:
1: <script language="javascript">
2: _spBodyOnLoadFunctionNames.push("HideBrandingsuite");
3: function HideBrandingsuite()
4: {
5: document.getElementById('suiteBarLeft').style.visibility = 'hidden';
6: }
7: </script>
As you can see, the code allows you to find the top navigation bar identified by “suiteBarLeft” and hide it by configuring the “visibility” property with the “hidden” value.
-
Save the page modifications and as expected, you can see how the top navigation bar is not shown any more for that page.
- If you want just to add some custom styles to the top bar, you can use similar JavaScript code:
1: <script language="javascript">
2: _spBodyOnLoadFunctionNames.push("HideBrandingsuite");
3: function HideBrandingsuite()
4: {
5: document.getElementById('suiteBarLeft').style.background='#000000';
6: }
7: </script>
-
In this case, we are just configuring the “background” property with a “black” value (#000000 code). If you save these modifications, you will see how the background of the top bar has changed to black.
And that’s all about how to customize top navigation bars in a SharePoint 2013 site. Of course, you can apply these kinds of customizations to the entire site by modifying the site master page.