Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!

An event handler for scroll events on element.

Syntax

element.onscroll = functionReference

Parameters

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

Example

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

  #foo {
    height:1000px;
    width:1000px;
    background-color: #777;
    display: block;
  }

  </style>
  </head>
  <body>
    <div id="container">
      <div id="foo"></div>
    </div>

    <script type="text/javascript">
      document.getElementById('container').onscroll = function() {
        console.log("scrolling");
      };
    </script>
  </body>
</html>

Notes

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

Specifications

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

문서 태그 및 공헌자

 최종 변경: bryanrsmith,