I have a sidebar menu that links to anchors on the page and on other pages. When I'm in the page the anchors work just fine, however when I go to an anchor on another page it offsets the height of the sticky header by more than it should. How can I get it to go to offset the header properly?
This is the code I'm using:
jQuery(function($) {
$('a[href^="#"]').live('click',function(event){
event.preventDefault();
var target_offset = $(this.hash).offset() ? $(this.hash).offset().top : 0;
//change this number to create the additional off set
var customoffset = 85;
$('html, body').animate({scrollTop:target_offset - customoffset}, 500);
});
}(jQuery));