WMJB
03-17-2005, 01:52 AM
I am trying to capture the onscroll event so that I can record what button or area a user clicked on a particular scrollbar.
There are two problems that are giving me grief.
1. The onscroll event fires ~40 times each time a scrollup or scrolldown button is pressed. This causes my onscroll= function to run over and over again where I only want it to run once!
2. The componentFromPoint() method returns the value from AFTER the scroll has taken place. So, if you click in the scrollbars track, immediately below the slider (or thumb) you are returned the value "scrollbarVThumb" instead of "scrollbarpagedown".
These two errors combined produce a very annoying effect. Check it out with the following sample HTML. Try clicking on the scrollbar, you have to click a few times to get rid of the alert box. (Or hold down the esc key).
<HTML>
<head>
<script>
function sayCheese(obj)
{
sElem = obj.componentFromPoint(event.clientX,event.clientY);
alert(sElem);
}
</script>
</head>
<body>
<div style="overflow: hidden;" style="height: 300; width: 20" >
<div id="divy" style="overflow-y: scroll;width:0;height:300;" onScroll="sayCheese(this);">
<div style="height: 1000px;width:1;">
</div>
</div>
</div>
</body>
</html>
Thanks guys.
W.
"It doesn't matter if I'm optomistic or not, nothing ever works out for me."
There are two problems that are giving me grief.
1. The onscroll event fires ~40 times each time a scrollup or scrolldown button is pressed. This causes my onscroll= function to run over and over again where I only want it to run once!
2. The componentFromPoint() method returns the value from AFTER the scroll has taken place. So, if you click in the scrollbars track, immediately below the slider (or thumb) you are returned the value "scrollbarVThumb" instead of "scrollbarpagedown".
These two errors combined produce a very annoying effect. Check it out with the following sample HTML. Try clicking on the scrollbar, you have to click a few times to get rid of the alert box. (Or hold down the esc key).
<HTML>
<head>
<script>
function sayCheese(obj)
{
sElem = obj.componentFromPoint(event.clientX,event.clientY);
alert(sElem);
}
</script>
</head>
<body>
<div style="overflow: hidden;" style="height: 300; width: 20" >
<div id="divy" style="overflow-y: scroll;width:0;height:300;" onScroll="sayCheese(this);">
<div style="height: 1000px;width:1;">
</div>
</div>
</div>
</body>
</html>
Thanks guys.
W.
"It doesn't matter if I'm optomistic or not, nothing ever works out for me."