<div id=oDiv1 onscroll=os()>
<div id=oDiv2>
...function os()
{
    oDiv2.scrollTop = event.srcElement.scrollTop;
}

解决方案 »

  1.   

    <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>
    TEXT TO HTML 
    </title>
    </head>
    <body bgcolor="#FFFFFF" style="background:url('joo.gif') center no-repeat fixed;">
    <table height="100%*" width="100%*" valign="middle">
      <tr valign="middle">
        <td>
          <table width="100%*" height="100%*" border="0" align="left" valign="middle">
            <tr>
              <td width="50%*">
                <textarea name="content" style="width:100%;height:95%;">            
                
                
                
                
                
                d
                d
                d
                d
                e
                e
                e
                e
                e
                e
                e            
                
                e
                e
                e
                e
                e
                e
                e
                e
    1
    2
    33
    1
    2
    33
                </textarea>
              </td>
              <td width="50%"> 
                <div id="panel" style="border:inset 1px;width:100%;height:95%;overflow:scroll;"></div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
    </body>
    <script language="JavaScript">
    contentFocused = true;
    panelFocused = false;
    content.onfocus = function() {
            contentFocused = true;
        }
    content.onblur = function() {
            contentFocused = false;
        }
    panel.onfocus = function() {
            panelFocused = true;
        }
    panel.onblur = function() {
            panelFocused = false;
        }
    content.onscroll = function() {
            if (contentFocused) {
                panel.scrollTop = content.scrollTop * (panel.scrollHeight - panel.clientHeight) / (content.scrollHeight - content.clientHeight);
            }
        }
    panel.onscroll = function() {
            if (panelFocused) {
                content.scrollTop = panel.scrollTop * (content.scrollHeight - content.clientHeight) / (panel.scrollHeight - panel.clientHeight);
            }
        }
    panel.innerHTML = "<pre>" + content.value + "</pre>";
    </script>
    </html>
      

  2.   

    <HTML>
    <HEAD>
    <TITLE>Chaser by Aaron Boodman</TITLE><STYLE TYPE='text/css'>
        #myChaser {
            position:absolute;
            left:200px;
            top:0px;
            width:250px;
            color:#555555; 
            font-family:verdana, arial, sans-serif;
            font-size:12px;
        }
    </STYLE></HEAD><BODY>
    <DIV ID='myChaser'>
    位置相对固定的层,可以任意设置。<br>
    </DIV>
    <SCRIPT LANGUAGE='JavaScript'>
    var oChaser = {
    topMargin : 25,
    callRate : 10,
    slideTime : 1200,
    maxDiff : document.all ? document.body.clientHeight : window.innerHeight,
    isIE : document.all ? true : false,
    chaserDiv : document[document.all ? "all" : "layers"]["myChaser"]
    }window.setInterval("oChaser.main( )", oChaser.callRate)
    oChaser.main = function( )
    {
    this.currentY = this.isIE ? this.chaserDiv.style.pixelTop : this.chaserDiv.top //pixelTop:该对象的top属性值,与top数值一样,但它是整型,不是字符型的值
    this.scrollTop = this.isIE ? document.body.scrollTop : window.pageYOffset //scrollTop:顶部滚动过的距离
    var newTargetY = this.scrollTop + this.topMargin if ( this.currentY != newTargetY ) { if ( newTargetY != this.targetY ) { this.targetY = newTargetY
    this.slideInit( )

    } this.slide( )

    }
    }
    oChaser.slideInit = function( )
    {
    var now = new Date( )

    this.A = this.targetY - this.currentY
    this.B = Math.PI / ( 2 * this.slideTime )
    this.C = now.getTime( ) if (Math.abs(this.A) > this.maxDiff) {
    this.D = this.A > 0 ? this.targetY - this.maxDiff : this.targetY + this.maxDiff
    this.A = this.A > 0 ? this.maxDiff : -this.maxDiff
    } else {
    this.D = this.currentY
    }
    }oChaser.slide = function( )
    {
    var now = new Date( )
    var newY = this.A * Math.sin( this.B * ( now.getTime( ) - this.C ) ) + this.D
    newY = Math.round( newY ) if (( this.A > 0 && newY > this.currentY ) ||
    ( this.A < 0 && newY < this.currentY )) {

    if ( this.isIE )this.chaserDiv.style.pixelTop = newY
    else this.chaserDiv.top = newY
    }
    }
    </SCRIPT>
    <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
    <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
    <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
    <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
    <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
    </BODY>
    </HTML>