I have an index.php page devided in sections. When clicking an element of the navbar the page scroll to the section.
I have another page called project.php which has the same navbar.
When clicking on a link (for instance the about link) I would like to come back to the main page ( the index.php) and scroll down to the about section (without clicking again on the navbar).
Everything works fine in the index page. But I can't manage to make it work from the project page.
Does anyone has an idea or maybe an alternative way to do it? Thanks a lot.
Here is my JS code
$(".navbar.main a[href^='#']").on('click', function(e){
window.location.replace("index.php");
var idMain = $(this).attr("href");
$('html, body').animate({scrollTop: $(idMain).offset().top -75}, 800);
e.preventDefault();
});