Click to See Complete Forum and Search --> : Scrolling layers trouble
Scragz
03-09-2003, 08:18 AM
Hi there,
I'm trying to write a script that will scroll a layer up and down the browser. The problem I have is adding a conditional limiter to stop the scrolling before the layer goes off the top of the browser. This is what I have so far and I doesen't seem to work.
var num = 0, timer;
function up() {
num++;
if (num==20){
window.clearTimeout(timer);
}
else if (document.all) test.style.top=parseInt (test.style.top) -1;
else if (document.layers) document.lyr.top -=1;
{timer = window.setTimeout ( "up()", 50);}
}
Scragz
03-09-2003, 04:21 PM
No it just carries on scrolling up the screen.
As you can probably tell i'm still in the process of learning javascript so your help is much appreciated.
Scragz
03-09-2003, 04:37 PM
I am not really sure if this is the best method to use for what I want to achieve. Basically I have got a small space to put a lot of text so I want to be able to scroll this text up to read it all. And I want to use rollover images to control the scrolling.
Scragz
03-10-2003, 07:32 AM
It comes up with various object expected and invalid argument errors when I rollover the button.
Scragz
03-10-2003, 08:05 AM
The ID is test.
Scragz
03-11-2003, 04:52 AM
Ok i've got it down to one error on line 38.
I've uploaded the page to www.simplyonline.net/test.html
Scragz
03-11-2003, 09:19 AM
Ok. I now get the error object expected on line 34.
Scragz
03-11-2003, 09:23 AM
Got it working now. Now is it the number after the parseInt line I change to adjust how far it scrolls up?
Scragz
03-12-2003, 09:15 AM
Cheers.
One last question what do you have to change to get it to scroll downwards?
Scragz
03-12-2003, 09:42 AM
Managed to work out how to scroll down. But now the problem is having a button for up and a button for down. Even though the code for each function is different they both do the same thing. I think it may be because it is returning to the first function or something.
Check the site to see what I mean: www.simplyonline.net/test
Scragz
03-13-2003, 07:25 AM
Almost there.
Now I find that when it scrolls to its limit i.e. <50 then you can't scroll down again because the function has returned false i'm guessing. It works fine if you don't scroll to the limits.
Scragz
03-13-2003, 08:54 AM
The code is exactly the same as what you displayed but once it scrolls to the limits it won't scroll back.
So if you scroll to the top then you can't scroll it back to the middle.
Scragz
03-16-2003, 12:53 PM
Can anyone help with the problem above.
The page the script is located on is: www.simplyonline.net/test