Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 links to act as up scroll/down scroll

Status
Not open for further replies.

sanka

IS-IT--Management
Nov 23, 2004
5
NL
I am very new to java, and have a problem. i wana make a java script to make the folowing happen:

allow two links(up/down) in hmtl scroll another frame.
the idea basicly is the scrolling html file is a menu and these links control the direction instead of using a scroll bar (up is the scroll up/down is the scroll down)

Thanks

Btw this site rox

 
First let me make one thing clear, there is a BIG difference between Java and JavaScript
second, if I'm not mistaking there should be a function called window.scroll(vertical,horizontal) that will scroll the window to a certain position... try playing around with it... My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
well, I dont know about a window.scroll(x,y) function, but I do know that you can use document.body.scrollTop and document.body.scrollLeft.

these are not functions, but rather read-write enviroment variables.

if you wanted a user to mouseover a link to scroll down the page, then just do something like this:

the link:
Code:
<div id=stick style=&quot;position:absolute; top:0; left:0;&quot;><a href=&quot;#&quot; onmouseover=&quot;scrollPageDown()&quot; onmouseout=&quot;stopScrolling()&quot;>scrollDown</a><a href=&quot;#&quot; onmouseover=&quot;scrollPageUp()&quot; onmouseout=&quot;stopScrolling()&quot;>Scroll Page Up</a></div>

and then the functions:
(the step variable is the distance the page jumps each move)
Code:
var step=15
var tim;
function scrollPageDown(){
document.body.scrollTop+=step;
//this next line just keeps the link in the same spot on the window
document.all.stick.style.pixelTop+=step;
tim=setTimeout('scrollPageDown()',50);}

function scrollPageUp(){
document.body.scrollTop-=step;
//this next line just keeps the link in the same spot on the window
if (document.all.stick.style.pixelTop>=step) {document.all.stick.style.pixelTop-=step}
tim=setTimeout('scrollPageUp()',50);}

function stopScrolling(){
clearTimeout(tim);}

I tested this code in ie 5.5, but my netscape 6 is not working at this time. it should work in netscape 6 tho. theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
hey thanks for that but just another Question how would i make it so that those buttons controled another frame,

eg, the buttons are in frame name 1 and the page i want to control is in frame name2????
 
here is a copy of the email response that sanka(ben) requested:


Ben-

say you have a frameset:
<frameset>
<frame .....(src and all that other junk).... name=content>
<frame .................................................. name=scroller>
</frameset>

then, you would put your content in the content frame and the scroller in
the scroll frame (duh!)

then, just modify the scroll code to this:
parent.content.document.body.scrollTop
and
parent.content.document.body.scrollLeft

but, here I have some disturbing news: I recently found out that ns does not
support the document.body object, thus rendering this script innefective!
one way for sure to test would be to try running the script I sent to you
previously in ns.

hope that helps,
the_eclipse
theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top