↓ Skip to main content

My Sticky Footer Solution for SharePoint 2013 – Pure JavaScript Solution

·2 mins
Tom Daly
Author
Tom Daly
Developer, Designer, Thinker, Problem Solver, 10x Microsoft MVP for M365, & Collaboration Director @ SoHo Dragon.

Last year I posted a blog article which described the issue with SharePoint 2010 and having a footer. Well similarly SharePoint 2013 has some of the same obstacles when adding a footer. If you are interested in reading more detail into the issue w/ 2010 then go here: My SharePoint 2010 Sticky Footer Solution.

It basically boils down to these 2 issues:

  1. If you just add a footer to your master page it will be displayed directly under the page content. On a page that has little content then the footer may show half way up the page.
  2. Alternatively if you try a pure CSS sticky footer solution it may not work correctly either because SharePoint uses the page height to calculate where the scroll bars will go (mainly due to the header / ribbon always being at the top).

[Update 10/9/2013] – Added code from Robert, to handle MDS type pages.

[Update 9/1/2013] – I noticed that these scripts do not work on Team Sites, this is due to the Minimal Download Strategy Feature that is enabled. Turn that off and this work perfectly fine. I’m still researching how to make the scripts how with that feature enabled.

I’ve also updated the code to use it’s own function to detect height. Padding (top/bottom) can sometimes throw off the size computations.

Link the script file#

As you can see below I’ve hosted my file in the Style Library

The Footer Control#

Simply add this div after s4-bodyContainer in the master page file.


© My Footer Solution 2013

As you can see below an export of the DOM from the IE Dev Toolbar.

footer

Here below you can see where in the Master Page (based on seattle.master) I look for the id=”DeltaPlaceHolderUtilityContent” and you’ll see 3

above it. I put it right between the 2nd & 3rd

mp_footer

The Script File
#

Download stickyFooter2013.js Here

This script is a pure JavaScript solution which will work with a default master page. If you customize it then you’ll need to account for any differences. It basically adds the suite bar + ribbon + body + footer, and if that’s smaller than the viewport aka viewable area. It will expand the body by the difference so that they are equal.

This also operates in it’s own namespace so there won’t be any collisions

I also bind to the window resize event so if the size of the screen changes the ribbon should stay on the bottom.

sf

Enjoy!

Related

Applying a Composed Look programmatically

·1 min
Applying a theme has change from SP2010 to SP2013, here is a link to the method to apply a composed look. SPWeb.ApplyTheme( string colorPaletteUrl, string…
↑