Chrome remembers scroll position

后端 未结 5 817
情话喂你
情话喂你 2020-12-05 04:52

I\'m running into a problem that\'s actually a \"feature\" on Chrome. As most of you might know, Chrome remembers a scroll position that it returns to, whenever you come bac

5条回答
  •  星月不相逢
    2020-12-05 05:35

    I solved this by attaching to scroll event, and then resetting scroll position the first time a user scrolls. Works for on-spot reloads for me.

    Looks like this:

    var scrollResetOnce = false;
    $(window).on("scroll", function() {
        if (scrollResetOnce) return;
        scrollResetOnce = true;
        scrollTo(0, -1);
    });
    

提交回复
热议问题