[英]It seemed that scroll event can fired during scrolling only when we use div scroll?
[英]Is the 'scroll' event guaranteed to be fired when scrolling programatically?
在Chrome中,如果我有onscroll
处理程序:
document.body.onscroll = function () {console.log('foo')}
...然后我以编程方式滚动文档:
document.body.scrollTop = 7
...然后触发onscroll
处理程序。
我可以在浏览器中依赖于此行为,还是仅将某些行为触发由用户操作引起的滚动处理程序? 这在任何地方都有吗?
我仍然不知道规范对此说了什么(如果有的话),但是我现在已经测试并确认该处理程序确实可以在以下最新版本中触发:
如果有要测试的平台, 请在其上弹出https://jsfiddle.net/14nckcw1/4/embedded/result/并等待; 如果您在1秒钟后看到警报,则程序化滚动将触发该平台上的onscroll
处理程序。 我不知道这不是事实。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.