Hi,
I have two frames in a window. The 'onscroll' event of a DIV in one frame should cause an offset in the DIV element of the other frame.
frame1 -> div1 ( when scrolled should cause an offset in )
frame2 -> div2
In other words, I need to be able to synchronize DIVs in two different frames. I am using this function for synchronizing:
function getOnScrollFunction(oElement) {
return function () {
if (oElement._scrollSyncDirection == "horizontal" || oElement._scrollSyncDirection == "both")
oElement.scrollLeft = event.srcElement.scrollLeft;
if (oElement._scrollSyncDirection == "vertical" || oElement._scrollSyncDirection == "both")
oElement.scrollTop = event.srcElement.scrollTop;
};
}
// This function adds scroll syncronization for the fromElement to the toElement
// this means that the fromElement will be updated when the toElement is scrolled
function addScrollSynchronization(fromElement, toElement, direction) {
fromElement._syncScroll = getOnScrollFunction(fromElement);
fromElement._scrollSyncDirection = direction;
fromElement._syncTo = toElement;
toElement.attachEvent("onscroll", fromElement._syncScroll);
}
The problem is, the need to be able to pass the event object from to this script, as the DIVs are in two different frames. I am using iframes in this case.
How can I pass the onscroll event between objects ? Can anyone help?
Thanks.
I have two frames in a window. The 'onscroll' event of a DIV in one frame should cause an offset in the DIV element of the other frame.
frame1 -> div1 ( when scrolled should cause an offset in )
frame2 -> div2
In other words, I need to be able to synchronize DIVs in two different frames. I am using this function for synchronizing:
function getOnScrollFunction(oElement) {
return function () {
if (oElement._scrollSyncDirection == "horizontal" || oElement._scrollSyncDirection == "both")
oElement.scrollLeft = event.srcElement.scrollLeft;
if (oElement._scrollSyncDirection == "vertical" || oElement._scrollSyncDirection == "both")
oElement.scrollTop = event.srcElement.scrollTop;
};
}
// This function adds scroll syncronization for the fromElement to the toElement
// this means that the fromElement will be updated when the toElement is scrolled
function addScrollSynchronization(fromElement, toElement, direction) {
fromElement._syncScroll = getOnScrollFunction(fromElement);
fromElement._scrollSyncDirection = direction;
fromElement._syncTo = toElement;
toElement.attachEvent("onscroll", fromElement._syncScroll);
}
The problem is, the need to be able to pass the event object from to this script, as the DIVs are in two different frames. I am using iframes in this case.
How can I pass the onscroll event between objects ? Can anyone help?
Thanks.