Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?

irt.org | Knowledge Base | JavaScript | Scroll | Q1103 [ previous next ]

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?

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.