The scroll
event of the VisualViewport
interface is fired when the visual viewport is scrolled.
The scroll
event of the VisualViewport
interface is fired when the visual viewport is scrolled.
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("scroll", (event) => {}); onscroll = (event) => {};
A generic Event
.
You can use the scroll
event in an addEventListener
method:
js
visualViewport.addEventListener("scroll", () => { // … });
Or use the onscroll
event handler property:
js
visualViewport.onscroll = () => { // … };
Specification |
---|
CSSOM View Module # eventdef-document-scroll |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
scroll_event |
6261Theonscroll event handler property is not supported. |
79 | 91 | No | 4948Theonscroll event handler property is not supported. |
13 | 6261Theonscroll event handler property is not supported. |
6261Theonscroll event handler property is not supported. |
68 | 4645Theonscroll event handler property is not supported. |
13 | 8.0 |
© 2005–2023 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