Click to See Complete Forum and Search --> : page scroll link. please.


monkey*tennis
02-17-2003, 10:26 AM
hi, java junior needing help here please...

want to have a link to scroll a page across to a specific pixel width, within a set sized window (not within frameset), and then a second link to scroll back.
i blagged code for the first scroll link, but couldn't adapt it to get the back link to work...

and suggestions, help, etc?

thanks x

khalidali63
02-17-2003, 11:00 AM
Here this will work with both (NS and IE) browsers


<script type="text/javascript">
function moveLeft(num){
window.moveBy(-(parseInt(num)),0);
}

function moveRight(num){
window.moveBy((parseInt(num)),0);
}
</script>
</head>

<body>
<p align="center">
<span onclick="moveLeft('5px');">Left(5px)</span>&nbsp;&nbsp;&nbsp;<span onclick="moveRight('5px');">Right(5px)</span>
</p>

monkey*tennis
02-17-2003, 11:18 AM
cheers, very swift, but not exactly what i was after - i should've explained better...

i need to scroll the CONTENTS within my browser window, and then scroll back.
The code that i gained for this is as follows:


<SCRIPT LANGUAGE="Javascript" TYPE="text/javascript">
<!--

var scrollPageRunning = false
function scrollPage(iStartPos,iEndPos) {
if (scrollPageRunning == false) {
scrollPageRun(iStartPos, iEndPos)
}
}

function scrollPageRun(iStartPos,iEndPos) {
iNextXPos = iStartPos + 10;
if (iNextXPos != iEndPos) {
scrollPageRunning = true
window.scroll(iNextXPos,0);
intervalID = setTimeout("scrollPageRun(" + iNextXPos + "," + iEndPos + ")",0.1);
} else {
scrollPageRunning = false
return false;
}
}

//-->
</SCRIPT>


then actioned by the following href:

<A HREF="javascript:scrollPage(0,418);" ONMOUSECLICK="window.status='right';return true">scroll right</A>


the problem was, i wasn't able to adapt it to create a working link that scrolled back.
The code probably contains more (or less) info than needed.
any chance you could help?
ta