Javascript DOM onscroll Event via HTML Tag onscroll attribute

Introduction

In HTML:

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
div {/*from  w w  w . j a v a  2s  .co  m*/
  border: 1px solid black;
  width: 200px;
  height: 100px;
  overflow: scroll;
}
</style>
</head>
<body>

<p>Try the scrollbar in div.</p>

<div onscroll="myFunction()">
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>
This is a test. <br><br>

</div>

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "You scrolled in div.";
}
</script>

</body>
</html>
Bubbles:
Cancelable:
Event type:
Supported HTML tags:

























No
No
UiEvent if generated from a user interface, Event otherwise
<address>,
<blockquote>,
<body>,
<caption>,
<center>,
<dd>,
<dir>,
<div>,
<dl>,
<dt>,
<fieldset>,
<form>,
<h1> to <h6>,
<html>,
<li>,
<menu>,
<object>,
<ol>,
<p>,
<pre>,
<select>,
<tbody>,
<textarea>,
<tfoot>,
<thead>,
<ul>



PreviousNext

Related