$(document).ready(function() { function staticNav() { var sidenavHeight = $("#navigation").height(); //Get height of sidenav var winHeight = $(window).height(); //Get height of viewport var browserIE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false; //Check for IE6 if (browserIE6) { //if IE6... $("#navigation").css({'position' : 'absolute'}); //reset the sidenav to be absolute } else { //if not IE6... $("#navigation").css({'position' : 'fixed'}); //reset the sidenav to be fixed } if (sidenavHeight > winHeight) { //If sidenav is taller than viewport... $("#navigation").css({'position' : 'static'}); //switch the fixed positioning to static. Say good bye to sticky nav! } } staticNav(); //Execute function on load $(window).resize(function () { //Each time the viewport is adjusted/resized, execute the function staticNav(); }); });