dom / latest / visualviewport / scroll_event.html /

VisualViewport: scroll event

The scroll event of the VisualViewport interface is fired when the visual viewport is scrolled.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener('scroll', event => { })

onscroll = event => { }

Event type

A generic Event.

Examples

You can use the scroll event in an addEventListener method:

visualViewport.addEventListener('scroll', function() {
  /* ... */
});

Or use the onscroll event handler property:

visualViewport.onscroll = function() {
  /* ... */
};

Specifications

Browser compatibility

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
62
61
The onscroll property is not supported.
79
91
66
No
49
48
The onscroll property is not supported.
13
62
61
The onscroll property is not supported.
62
61
The onscroll property is not supported.
68
46
45
The onscroll property is not supported.
13
8.0

See also

© 2005–2021 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