When I visit my_site.com/page.php#something
, the scroll position is the one of the element carrying this particular hashtag rather than the top of the page.
Having this HTML code:
link
You can avoid scrolling to the div element and instead scrolling to the top of the window by using this code:
$("a").on("click", function(e) {
e.preventDefault();
window.scrollTo(0, 0);
});
EDIT:
You can try to add this:
var firstVisit = true;
$(window).scroll(function() {
if (firstVisit) {
window.scrollTo(0, 0);
firstVisit = false;
}
});