How to trigger an on scroll event without scrolling

前端 未结 8 1211
梦毁少年i
梦毁少年i 2021-02-12 03:15

my Question is, how can i trigger (simulate or something esle) an on scroll event. In my special case I don\'t want to load all the Conservations in LinkedIn by scolling down al

8条回答
  •  遥遥无期
    2021-02-12 03:56

    As everybody replied, window.scrollTo(window.scrollX, window.scrollY); is work truly but in some cases, you should add a number to the windows current scroll position, for example in my case I added 1 to my scrollY and then called scrollTo method like this:

    window.scrollTo(window.scrollX, window.scrollY + 1);

提交回复
热议问题