Forum Moderators: open

Message Too Old, No Replies

Finding position of scrollbar.

         

prashantp

6:25 am on Feb 28, 2005 (gmt 0)

10+ Year Member



Hi,

i've created a scrollbar around a table using a div tag and its overflow css property. is there anyway i can find the position of the scrollbar.

i came across scrollTo and other functions.

hope there is a way around to solve this issue.

regards,
Prashant

SpaceFrog

8:38 am on Feb 28, 2005 (gmt 0)

10+ Year Member



alert (document.object.scrollTop)

prashantp

9:08 am on Feb 28, 2005 (gmt 0)

10+ Year Member



its not working. it always gives value as zero even if i change the position of the scrollbar.

This is the div <div id="x">
then the table, on overflow scrollbars come.

onUnload of page i set the position using
document.getElementById("x").scrollTop

then i reaslised that that was for the vertical scroll bar, and since my scrollbar is a horizontal one i used scrollLeft.
both the params give me value as zero.

SpaceFrog

9:45 am on Feb 28, 2005 (gmt 0)

10+ Year Member



Try this it may help you understand ...

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Scroll</title>
<script>

function showscroll(posTop,posLeft){
document.getElementById('scrollpos').value=posTop+" ; " +posLeft;
}
</script>
</head>

<body>
<input type='text' id='scrollpos' />
<div style="height :100%;width:100%; overflow:auto;" onscroll="showscroll(this.scrollTop,this.scrollLeft)">
<div id="scroller" style="height:5200px;width:6000;" >&nbsp;</div>
</div>

</body>
</html>