Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1103 Is it possble to have a freeze panes effect like that in excel using frames, where scrolling in one frame automatically makes another frame scroll?

You are here: irt.org | FAQ | JavaScript | Scroll | Q1103 [ previous next ]

It would have to use the onScroll and would therefore only work in Internet Explorer 4+ Although Netscape has mentioned onScroll, I have not seen it in their documentation.

A more compatible way would be to put the following in a third frame:

<script language="JavaScript"><!--
function myVoid() { ; }

CurrentX = 0;
CurrentY = 0;

function myScroll(Direction) {
   if (!document.images) return; // not supported

   var Increment = 10;

   if (Direction == 'down') CurrentX += Increment;
   else if (Direction == 'up') CurrentX -= Increment;
   else if (Direction == 'right') CurrentY += Increment;
   else if (Direction == 'left') CurrentY -= Increment;

   top.frames[0].scroll(CurrentX,CurrentY); // alternative is scrollTo(x,y)
   top.frames[1].scroll(CurrentX,CurrentY);
}
//--></script>

<a href="javascript:void(0)" onMouseOver="myScroll('down')">down</a>
<a href="javascript:void(0)" onMouseOver="myScroll('up')">up</a>
<a href="javascript:void(0)" onMouseOver="myScroll('left')">left</a>
<a href="javascript:void(0)" onMouseOver="myScroll('right')">right</a>

Note: for Netscape, try parent.framename.scrollTo(0,20) or parent.framename.scrollBy(0,20) - since scroll was deprecated in Netscape 4.0.

Feedback on 'Q1103 Is it possble to have a freeze panes effect like that in excel using frames, where scrolling in one frame automatically makes another frame scroll?'

©2018 Martin Webb