onscrollEvent

事件对象参考手册Event Object

Examples

Execute JavaScript when the <div> element is scrolled

<div onscroll="myFunction()">

Try it Yourself »


Definition and Usage

The onscroll event triggers when an element's scrollbar is being scrolled.

Tip:Use CSSoverflowstyle property to create an element's scrollbar.


Browser Support

Event
onscroll Yes Yes Yes Yes Yes


Syntax

In HTML:

<element onscroll="myScript">Try it Yourself

In JavaScript:

object.onscroll=function(){myScript};Try it Yourself

In JavaScript, using the addEventListener() method:

object.addEventListener("scroll", myScript);Try it Yourself

Note:Internet Explorer 8 and earlier IE versions do not supportaddEventListener()the method.


Technical Details

Technical Details

Does it support bubbling: Yes
Can it be cancelled: No
Event type: Event
Supported HTML tags: <address>, <blockquote>, <body>, <caption>, <center>, <dd>, <dir>, <div>, <dl>, <dt>, <fieldset>, <form>, <h1> - <h6>, <html>, <li>, <menu>, <object>, <ol>, <p>, <pre>, <select>, <tbody>, <textarea>, <tfoot>, <thead>, <ul>


事件对象参考手册Event Object

Other Extensions