Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

onscroll event

onscroll event

Event Object Reference Event Object

Example

Execute JavaScript when an element is scrolled.
<div onscroll="myFunction()">

Try it »


Definition and Usage

The onscroll event is triggered when the scrollbar of an element is scrolling.

Tip: Use CSS overflow style attribute to create a scrollbar for the element.


Browser support

Event
onscroll Yes Yes Yes Yes Yes

Syntax

In HTML:

<

element

onscroll="

myScript

">

Try it

In JavaScript:

object

.onscroll=function(){

myScript

};

Try it

In JavaScript, use the addEventListener() method:

object

.addEventListener("scroll",

myScript

);

Try it

Note: Internet Explorer 8 and earlier IE versions do not support addEventListener() method.


Technical Details

Technical Details

    ,,,
    Does it support bubbling: Yes
    Is it cancelable: No
    Event type: Event
    Supported HTML tags:
    ,
    , ,
    ,
    ,
    , ,
    ,
    ,
    ,
    ,
    ,

    -

    , ,
  • , , ,
      ,

      ,

      , 

  • Event Object Reference Event Object