synchronization of one div with another

S

sumit

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,,,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top