Synchronize 2 frames

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am trying to synchronize 2 frames with  code as shown below but it
only works in IE5.2 for the Mac, in Safari or in IE6 for Windows it
does not work.
Is there a solution for this?

Gerard Jonker
The Netherlands

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
" ">
frame scrolling synchronization
var tid;
function initScrollSynchronization () {
  tid = setInterval('syncFrame()', 25);
function syncFrame () {
  if (document.all && !window.opera) {
    var scrollTop = frame0.document.body.scrollTop;
    var scrollLeft = frame0.document.body.scrollLeft;
  else {
    var scrollTop = frame0.pageYOffset;
    var scrollLeft = frame0.pageXOffset;
  frame1.scrollTo (scrollLeft, scrollTop);
<FRAMESET COLS="50%, 50%" ONLOAD="initScrollSynchronization()">
<FRAME NAME="frame0" SRC="file1.html">
<FRAME NAME="frame1" SRC="file2.html">


Re: Synchronize 2 frames

Gerard Jonker wrote:

Quoted text here. Click to load it

Don't use frames. /

Re: Synchronize 2 frames

Quoted text here. Click to load it
Thanks for your advice, it was very useful to me.

I have created a construction with a single document using fixed
position elements. However,  I want to be able to scroll part of the
document horizontally, while maintaining its vertical position. Is
there a way to do this using CSS? I have not found one in the official
CSS documentation.

Gerard Jonker

Re: Synchronize 2 frames

In article Gerard Jonker wrote:
Quoted text here. Click to load it

Nice to know. It usually doesn't help to imitate frames using CSS though.

Quoted text here. Click to load it

I don't think that is best aproach. But I don't have any idea what you
are doing, so it is really hard to tell. If this is going to be normal
webpage for normal web audience, I think you need to rethink your

Quoted text here. Click to load it

This is almost possible using absolute positioning, and overflow:scroll.
Quick & dirty example:

The problem is that horizontal scrollbar is likely to be outside viewport
most of the time, so you need to assume people know how to scroll
horizontally whitout it. Too bad it is impossible in some browsers
(tested on O7.21). Using iFrame instead scrolling div would propably help
0.1% of normal web audience that know how to scroll horizontally whitout
scrollbar. Then you could add some JS scrollbar. But it wouldn't work for
lots of people. I don't think there is better way, unfortunately.

If you can scroll overflow:auto element using JS, I think it would be
somewhat easy to make it degrade well (whole page would be horizontally
scrolled). But I don't know if that is possible using JS+DOM.

Lauri Raittila < <
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Site Timeline