I have a website that has anchor links on the front page that link to different sections of the page. I have ran into an issue with the secondary pages where whenever they click on the anchor links that reference the sections on the main page it does not take them to the section. I have tried to use the full URL http://www.website.com/index.php#1 but that only takes be to the main page but does not trigger the location of the anchor link. Is there something i'm missing?
I'm using the following Jquery for the smooth scroll and to activate a menu rollover whenever they are at a certain section.
<script>
var timerid; //Used to fire scroll function once after scrolling is done.
$(document).ready(function(){
$("#menu-main-menu a").click(function(e){
e.preventDefault();
$("#menu-main-menu a").removeClass('active');
var id = $(this).attr("href").substring(1);
$("body").animate({
'scrollTop': $("section#" + id).offset().top -133
});
});
$("body").scrollTop(1); //forcing window scroll to execute on page load
$(window).scroll(function(){
clearTimeout(timerid);
timerid = setTimeout(checkactivelink, 50);
});
function checkactivelink()
{
$("section").each(function(){
if($("body").scrollTop() >= $(this).offset().top -133)
{
$("#menu-main-menu a").removeClass('active');
$("#menu-main-menu a[href=#" + $(this).attr("id") + "]").addClass('active');
}
});
}
});
</script>