Hi, I have a “nearly”-Onepage-Layout. I link to my content using anchors. Since I have a fixed header, I need to offset scrolling by 125 pixels.
That works fine for links on the same page using this jquery:
jQuery(function($) { $('a[href*="#"]:not([href="#"])').click(function(e) { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') || location.hostname == this.hostname) { var target = $(this.hash); headerHeight = 120; target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').stop().animate({ scrollTop: target.offset().top - 125 //offsets for fixed header }, 'linear'); } } }); });
Unfortunately I have on other page (the disclaimer). When I link to the disclaimer, it’s no problem, but when I link back to an anchor on the main page, the anchor is hidden behind the menu bar.
How can I get it to scroll the additional 125 pixels?