// Create a sticky widget var STICKY = {} // Start a timer on window scroll to prevent firing lots of extra functions STICKY.timer = setTimeout(function(){}) // Only do the following if the browser isn't IE 6 if(!$('html.ie6')[0]) { // Add 'back to top' links, except in IE 6 $('#container') .append('<div id="back-to-top"><a href="#">Back to top</a></div>') .append('<div id="back-to-top-2"><a href="#">Back to top</a></div>') $('#back-to-top').hide() .css({ 'top': '0px' }) $('#back-to-top-2').hide() .css({ 'bottom': '0px' }) // Clone the sticky nav $('#sticky-nav').parent().append($('#sticky-nav').clone().attr('id', 'sticky-nav-clone').hide()) $(window).scroll(function(){ clearTimeout(STICKY.timer) STICKY.timer = setTimeout(function(){ STICKY.makeSticky("#back-to-top") STICKY.makeSticky("#sticky-nav-clone") STICKY.makeSticky("#back-to-top-2", true) }, 50) }) }