We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

Nasi wolontariusze nie przetłumaczyli jeszcze tego artykułu na język Polski. Dołącz do nas i pomóż go przetłumaczyć!
Można także przeczytać artykuł w języku: English (US).

An event handler for scroll events on element.


element.onscroll = functionReference


functionReference is a reference to a function to be executed when element is scrolled.


<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8" />
  #container {
    position: absolute;
    height: auto;
    top: 0;
    bottom: 0;
    width: auto;
    left: 0;
    right: 0;
    overflow: auto;

  #foo {
    background-color: #777;
    display: block;

    <div id="container">
      <div id="foo"></div>

    <script type="text/javascript">
      document.getElementById('container').onscroll = function() {


The scroll event is raised when the user scrolls the contents of an element. Element.onscroll is equivalent to element.addEventListener("scroll" ... ).


Specification Status Comment
Document Object Model (DOM) Level 3 Events Specification
The definition of 'onscroll' in that specification.
Obsolete Initial definition

Browser Compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) ? ? ? ?
Feature Android Android Webview Chrome for Android Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes) (Yes) (Yes) ? ? ? ? ?

Autorzy i etykiety dokumentu

 Ostatnia aktualizacja: erikadoyle,