我正在使用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:不,我只是想在每次刷新後在最上面加載頁面。這就是全部 –