如何在不滚动的情况下触发滚动事件
我的问题是,我该如何触发(模拟或其他事情)滚动事件.在我的特殊情况下,我不想通过缩小所有保护区来加载LinkedIn中的所有保护区,因为太多了!
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 all conservations, because there are too many!
我不需要PHP或Javascript解决方案.只需在chrome上使用开发工具就可以实现我的目标.
I do not need a PHP or Javascript solution. Simply using dev-tools at chrome is enough to get my goal.
或者,您可以手动触发实际的 scroll
事件,如下所示:
Alternatively, you can manually trigger a real scroll
event as following:
el.dispatchEvent(new CustomEvent('scroll'))
与通过 +1
和 -1
像素进行双滚动的感觉相比,感觉更少的黑客攻击(而且性能更高)...
Which feels a bit less of a hack (and more performant) than dual scrolling by +1
and -1
pixels...
这应该运行任何侦听 scroll
事件的代码.
This should run any piece of code listening for a scroll
event.
要支持 IE11
或其他旧版浏览器,请考虑使用 CustomEvent
polyfill,例如 mdn-polyfills
To support IE11
or other legacy browser, consider using a CustomEvent
polyfill such as mdn-polyfills