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.