我正在使用fullPage.js插件逐页滚动。该插件使用哈希URL来完成。在页面刷新时,文档始终在最后一个哈希链接上加载。如何在每次刷新后将文档加载到顶部?我尝试添加以下代码,但没有奏效:每次刷新后在index.html加载页面
$(document).ready(function(){
$(document).scrollTop(0);
});
这是链接到的网页 - 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');
}
}
});
链接的github仓库:https://github.com/rimildeyjsr/St.Anthony-Website
你是否试图定期刷新页面? – xtechkid
我一直没有用过哈希,但问题是,如果你坚持在控制台中,这是否导致页面跳回到顶部? 'window.location.hash ='';' – Taplar
@xtechkid:不,我只是想在每次刷新后在最上面加载页面。这就是全部 –