
interesting problem with scrolling
Juan,
this is a quick 5 minute coding so it could be easily improved but it will
give you an idea of how this can be done...
-------[cut]------
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function scr(x) {
if (x==1) {
myDiv2.scrollTop = myDiv1.scrollTop;
myDiv2.scrollLeft = myDiv1.scrollLeft;
} else {
myDiv1.scrollTop = myDiv2.scrollTop;
myDiv1.scrollLeft = myDiv2.scrollLeft;
}
Quote:
}
//-->
</script>
</head>
<body>
<div id="myDiv1" style="height:100px;width:100px;overflow:scroll;"
onscroll="scr(1)">
<table width="200" height="200" cellspacing="0" cellpadding="0"
border="0">
<tr><td> </td></tr>
</table>
</div>
<div id="myDiv2" style="height:100px;width:100px;overflow:scroll;"
onscroll="scr(2)">
<table width="200" height="200" cellspacing="0" cellpadding="0"
border="0">
<tr><td> </td></tr>
</table>
</div>
</body>
</html>
-------[cut]------
I have filled the divs with tables twice the size so that the <div>s will
have content to scroll, I am also assuming that the <div>s both have content
the same size. However if they are not, as simple bit of maths could be
used.
Hope this is what you were looking for...
Ric.
Quote:
> The problem I am looking at is that I have 2 <div>s next
> to each other. For <div>#2 I got the horizontal scroll
> and the vertical scroll to work. But when I scroll up and
> down on #2 I need #1 to mimic the scroll direction and
> distance. I know using the fireEvent() method might be
> necessary. But, the difficult thing is calculating the
> distance traveled for each scroll. Does anyone have any
> ideas. I appreciate the input. Thanks