Rimil Dey Rimil Dey - 11 days ago 7
HTML Question

Load the page at index.html after every refresh

I am using the fullPage.js plugin to scroll page by page. The plugin is using hash urls to do so. On page refresh, the document is always loading on the last hash url it was on. How to make the document load at the top after every refresh? I tried adding the following code but it did not work out:

$(document).ready(function(){
$(document).scrollTop(0);
});


This is the link to the webpage - https://rimildeyjsr.github.io/St.Anthony-Website

jQuery :

$('#fullpage #section1').hide();
$(document).ready(function(){
$('#fullpage #section1').show();
$('#fullpage').fullpage({
anchors:['Page1','Page2','lastpage'],
afterLoad : function(anchorLink,index) {
if (index == 2 || anchorLink == 'Page2'){
$('.school-name').addClass('animated slideInUp').css('visibility','visible');
}
}

});


Link to github repository : https://github.com/rimildeyjsr/St.Anthony-Website

Answer

It looks like this on your page causes it to go back to the top.

window.location.hash = '#Page1';

So you could try doing that

$(window).on('load', function() {
    window.location.hash = '#Page1';
});

which should happen any time you load the page, including refreshing.