This feature is well established and works across many devices and browser versions. It’s been available across browsers since August 2021.
The scroll event of the VisualViewport interface is fired when the visual viewport is scrolled. This allows you to position elements relative to the visual viewport as it is scrolled, which would normally be anchored to the layout viewport.
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("scroll", (event) => { })
onscroll = (event) => { }
A generic Event.
See the Visual Viewport API landing page for a usage demo.
| Specification |
|---|
| CSSOM View Module> # eventdef-document-scroll> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
scroll_event |
6261–62Theonscroll event handler property is not supported. |
79 | 91 | 4948–49Theonscroll event handler property is not supported. |
13 | 6261–62Theonscroll event handler property is not supported. |
68 | 4645–46Theonscroll event handler property is not supported. |
13 | 8.0 | 6261–62Theonscroll event handler property is not supported. |
13 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport/scroll_event