我的scrollTop JavaScript代碼只適用於Firefox。我在href鏈接上放置了一些錨點,並且只有在chrome/explorer才能處理平滑滾動。在Firefox上沒有。它只在該按鈕上跳轉,但不會滾動到該按鈕。ScrollTop js - Firefox不起作用
Firefox控制檯錯誤:此站點似乎使用滾動鏈接的定位效果。這可能不適用於異步平移;請參閱https://developer.mozilla.org/docs/Mozilla/Performance/ScrollLinkedEffects瞭解更多詳情,並加入相關工具和功能的討論!
我的代碼:
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
$scrollWrapper = $(document);
scroll = function scroll(value, hash) {
$scrollWrapper.scrollTop(value);
currentHash = hash;
};
} else {
$scrollWrapper = $('html, body');
scroll = function scroll(value, hash) {
$(document).off('scroll.currentHash');
$scrollWrapper.animate({
scrollTop: value + 30
}, {
delay: 500,
complete: function() {
currentHash = hash;
}
});
};
}
可能重複的[jQuery的scrollTop的Firefox中不工作(http://stackoverflow.com/questions/17776544/jquery-scrolltop-firefox-not-working) – tmslnz
嘗試:'$ scrollWrapper = $(窗口);' –
「Firefox scrollTop stackoverflow」返回了不少結果。你看過這些嗎? – tmslnz