How to trigger an on scroll event without scrolling

前端 未结 8 1222
梦毁少年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 04:06

    You absolutely need a Javascript solution. What else is going to do the event listening/triggering, do you think?

    If you want to fire a scroll event, just literally scroll to where you already are by typing window.scrollTo(window.scrollX, window.scrollY); in your scripts or dev tools console. Alternatively, you can fake one using a combination of CustomEvent and the dispatchEvent function.

    If you want to trigger something on a scroll event, listen for scrolls using window.addEventListener("scroll", function(evt) { ... }); and make the handling function do whatever it is you need to do.

提交回复
热议问题