Click to See Complete Forum and Search --> : scrolling of one div should cause scrolling og another div


sumita
11-17-2003, 10:23 AM
Hi,
My requirment is to synhcronize scrolling of two divs,,
If I scroll one unit the other div should also get
scrolled by one unit,,
For this I have written a javascript func ScrollUpper()
which is called on onScroll() event of first div,,
DivRealMedia is first div id
DivDummy is second div id
function is:
function ScrollUpper()
{
if (DivRealMedia.scrollLeft == 0 ||
DivRealMedia.scrollLeft == prevLeft)
{
prevLeft = DivRealMedia.scrollLeft;
}
else
{
if (DivRealMedia.scrollLeft < prevLeft)
{
prevLeft = DivRealMedia.scrollLeft;
DivDummy.doScroll("scrollbarLeft");
}
if (DivRealMedia.scrollLeft > prevLeft)
{
prevLeft = DivRealMedia.scrollLeft;
DivDummy.doScroll("scrollbarRight");
}
}
}

But It is not synchronized as required. DivDummy should
move with same unit as that of DivRealMedia.

Please suggest me how it can be achieved!!

Thanks,,,
.