/    Sign up×
Community /Pin to ProfileBookmark

synchronize 3 frames

Hi to all.

I have a big problem,with this code I can synchronize 2 frames:
///Scroll Right
<script type=”text/javascript”>
var _run; // Set an empty variable named “_run”

if(navigator.userAgent.indexOf(“Firebird”)!=-1||navigator.userAgent.indexOf(“Firefox”)!=-1||navigator.appName==”Microsoft Internet Explorer”) // if the browser is Firebird/Firefox or MSIE
{_run=false;} // set the variable _run to false
else {_run= true;} // otherwise, set _run to true

function scrollR() // begin function scrollR()
{
var left = (window.pageXOffset)?(window.pageXOffset)?document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft;
/* If window.pageXOffset is defined, set left to the pageXOffset of the current document. If it isn’t and document.documentElement is defined, set left to document.documentElement.scrollLeft. If document.documentElement and window.pageXOffset are both undefined, set the variable to document.body.scrollLeft */
var top = (window.pageYOffset)?(window.pageYOffset)?document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;
/* An explanation here: the variable “top” is going to represent one of three things: window.pageYOffset (if it is available, if it’s not, it represents document.documentElement.scrollTop. If document.documentElement is not available, it will represent document.body.scrollTop (sound familiar?). This is the variable we’ll use to determine the amount of pixels this document is scrolled from the top. It is important because it tells us where we should put the frame on the right. */

parent.frames[“left”].scrollTo(left,top);

/* Now scroll the left frame to the amount of pixels this document is from the left. If you scroll 3 pixels from the left (to the right) on this frame, the left document will be scrolled by exactly the same amount. This is how the frames are synchronized. */
} // End function scrollR

function searchScroll(){
var left = (window.pageXOffset)?(window.pageXOffset)?document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft;
/* This is the same as was what we created earlier. Here, we set the variable (in pixels) indicating where the document has been scrolled from the left to the right. */
var top = (window.pageYOffset)?(window.pageYOffset)?document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;

/* Again, we’re setting the variable “top” to equal the amount of pixels the document is scrolled from the top of the window, and using it to calculate how far from the top the opposite frame should scroll. .*/

parent.frames[“left”].scrollTo(left,top); /* scroll the left frame to wherever this frame is scrolled to */
window.setTimeout(“searchScroll();”,1); /* run this function one time every millisecond, or 1,000 times a second */
}

if(_run == false) // if _run was set to false
{
window.onscroll=function(){scrollR();} /* run the function scrollR() when the document is scrolled */
} else { // if the variable _run is set to true
window.onload=function(){searchScroll()} /* when the document loads, run the searchScroll() function 1,000 times a second (because there is a setTimeout() function inside the searchScroll() function). */
}
</script>

////Scroll Left
<script type=”text/javascript”>
var _run;

if(navigator.userAgent.indexOf(“Firebird”)!=-1||navigator.userAgent.indexOf(“Firefox”)!=-1||navigator.appName==”Microsoft Internet Explorer”)
{_run=false;}
else {_
run= true;}

function scrollL()
{
var left = (window.pageXOffset)?(window.pageXOffset)?document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft;
var top = (window.pageYOffset)?(window.pageYOffset)?document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;

parent.frames[“right_up”].scrollTo(left,top);

/* Scroll the right frame to wherever this frame is scrolled to */
}
function searchScroll(){
var left = (window.pageXOffset)?(window.pageXOffset)?document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft;
var top = (window.pageYOffset)?(window.pageYOffset)?document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;

parent.frames[“right”].scrollTo(left,top);
window.setTimeout(“searchScroll();”,1);
}
if(_run == false)
{
window.onscroll=function(){scrollL();} /* run function scrollL() when this document is scrolled, remember this function scrolls the right frame, so it causes both frames to scroll at the same time */
} else {
window.onload=function(){searchScroll()} /* run function searchScroll() which scrolls the right frame. This function runs a thousand times a second, so it has a small delay, unlike the scrollL() function. This is because it is unsupported by browsers other than Firefox and MSIE. */
}
</script>

This code work’s correctly, but the problem that I have it’s that I need to synchronize 3 frames but I can’t and I need to do that.Somebody have a solution o maybe when I can find information about this problem. And other question it’s possible that in the third frame the synchronization be only left-right and right-left.

Thank you and sorry for my bad English.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Warren86Dec 10.2004 — I'm not certain that I understand what you want to do. But, I'm attaching a file, which contains code for 3 frames, top, mid and bottom. When the user scrolls the TOP frame, the other two track that scrolling.

[upl-file uuid=99a815e9-aadd-43a2-8412-c284a3b3538f size=7kB]track scroll 2 dependent frames.txt[/upl-file]
Copy linkTweet thisAlerts:
@tlahuicoleauthorDec 10.2004 — Thank you for you post. I'am analyzing the code.
×

Success!

Help @tlahuicole spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...