...

View Full Version : Left-Right Manual Scroller



Ultragames
08-27-2002, 12:56 AM
I have seen them. They have an arrow on the left, and one on the right, and when you put your mouse over them, it scrolls that direction.

I need a scroller that does this. I need to be able to use pics for the arrows, have the height and width adjustable, (That shouldn't be a prob) and be able to have a background image!!

This is one heafty script but at least I know just what I need. If you guys can find or creat one for me, THANKS!!

UG;)

beetle
08-27-2002, 02:24 AM
First, let's clarify this. What container do you want to scroll content in? A DIV? An IFRAME? Or are you unsure?

Ultragames
08-27-2002, 07:11 AM
I want to scroll text. Links to be infact. I could use a div, or an iframe might work too.

I would prefere an iframe now that you mention it because I need to stablize the background. I will also need help with that from some where. I have found scripts that say they do that but I have yet to get them to work.

Also, if at all posible I would need the scrolling arrows to either be outside of the iframe. Like so...
{IMG} {IFRAME}content{/IFRAME} {IMG}

Thank you for any work you may put forth into finding or creating these scripts.

UG:thumbsup:

beetle
08-27-2002, 03:29 PM
Here's a simple script for horizontally scrolling an IFrame
var scrollSpeed = 20;
var scrollDir = "";
var f = document.frames['iframeName']; // Your IFrame

function startScroll(direction) {
scrollDir = direction;
scrollFrame();
}

function scrollFrame() {
if (scrollDir == 'left')
f.window.scrollBy(scrollSpeed - scrollSpeed*2,0);
else if (scrollDir == 'right')
f.window.scrollBy(scrollSpeed,0);
scrolling = setTimeout('scrollFrame();',scrollSpeed);
}

function stopScroll() {
clearTimeout(scrolling);
}

(...HTML...)

<img src="arrow_left.gif" onMouseDown="startScroll('left')" onMouseUp="stopScroll();" />This is pretty similar to the scroller I use at my site, www.peterbailey.net Click on 'Workshop' and you should see what I mean

Ultragames
08-27-2002, 08:26 PM
I think were getting there. I arranged your code in Frontpage for a test and it didn't work. Here is how I arranged it. If theres something wrong, please let me know.



<html>

<head>

<script>
var scrollSpeed = 20;
var scrollDir = "";
var f = document.frames['slider']; // Your IFrame

function startScroll(direction) {
scrollDir = direction;
scrollFrame();
}

function scrollFrame() {
if (scrollDir == 'left')
f.window.scrollBy(scrollSpeed - scrollSpeed*2,0);
else if (scrollDir == 'right')
f.window.scrollBy(scrollSpeed,0);
scrolling = setTimeout('scrollFrame();',scrollSpeed);
}

function stopScroll() {
clearTimeout(scrolling);
}
</script>
</head>

<body>
<img src="arrow_left.gif" onMouseUp="startScroll('left')" onMouseDown="stopScroll();">
<iframe SRC="http://www.koin6.com" NAME="slider" WIDTH="100" HEIGHT="100" FRAMEBORDER="0"></iframe>
</body>

</html>

Ultragames
08-27-2002, 09:18 PM
I have narrowed down the problem for you. I get an error saying that f.window is either null of not on object. What might this be?

Ultragames
08-29-2002, 03:55 AM
Anyone out there? I hope you are stil able to help Beetle!

Thx again. . .

Quiet Storm
08-29-2002, 04:11 AM
If I'm looking at this right (without testing it), the script part of it should be on the iFrame page...

And the controls be on the main page.

That's what had to be done for my vertical scrollers...

Ultragames
08-29-2002, 07:03 AM
Thanks, I'll try it later.... Get back to you soon.

Ultragames
08-29-2002, 07:17 PM
Nope. I put the script on the iframe page. Now the error says 'Object expected'

you still there beetle?

beetle
08-29-2002, 07:56 PM
Sorry, I'm really busy right now, but this may help

var f = document.frames['slider']; // Your IFrame

Is that reference accurate for your iframe? you may need top.frames or parent.frames or something like that. If f.window is causing an error, it is because f is incorrect.

All the code should go on the same page.

Ultragames
08-29-2002, 09:01 PM
ok, so where do I put the 'top.frames or parent.frames' thing?

And if your asking if my iframe is named slider then yes. Other than that I dont know about acuracy.

are you saying it must be liek this???


var f = top.frames['slider']; // Your IFrame

Ultragames
08-29-2002, 09:12 PM
f.window.scrollBy(scrollSpeed - scrollSpeed*2,0);
f.window.scrollBy(scrollSpeed,0);

one of those is null or is not an object.



Now that I put

var f = top.frames['slider']; // Your IFrame

instead of:

var f = document.frames['slider']; // Your IFrame

it says 'scrolling' is undefined.

might I need to put something in the iframe code?
Better idea: I could just use a div I guess. This would make it easyer I hope?? Then you could just give me the code you used for you site. . .

beetle
08-29-2002, 09:26 PM
Hm, try adding scrolling to the declaring section
var scrollSpeed = 20;
var scrollDir = "";
var f = document.frames['slider']; // Your IFrame
var scrolling;

Ultragames
08-29-2002, 10:26 PM
Ok, that took care of the scrolling error. Now theres just the 'f.window' error. Heres what I have now. . .



<script>
var scrollSpeed = 20;
var scrollDir = "";
var f = top.frames['slider']; // Your IFrame
var scrolling;

function startScroll(direction) {
scrollDir = direction;
scrollFrame();
}

function scrollFrame() {
if (scrollDir == 'left')
f.window.scrollBy(scrollSpeed - scrollSpeed*2,0);
else if (scrollDir == 'right')
f.window.scrollBy(scrollSpeed,0);
scrolling = setTimeout('scrollFrame();',scrollSpeed);
}

function stopScroll() {
clearTimeout(scrolling);
}
</script>

beetle
08-29-2002, 10:40 PM
Hrm. Can I see your page? Or at least some code?

Ultragames
08-29-2002, 11:00 PM
Digital Designs (http://home.attbi.com/~digitaldesigns/twopointo/index2.htm)

Put your mouse over the logo and choose links. That is one of the pages I want to scroll. The smaller green arrows are what you are supposed to use to scroll. If you try it is say 'Error on page'

beetle
08-29-2002, 11:22 PM
Got it.

The variables that are being declared at the top of the script sections are coming in to early (frame isn't loaded yet. So, what we need to do is add on onload the sets them for us. I'm not looking at my page so I don't remember why my situation was different, but nonetheless, it should work.
var scrollSpeed = 20;
var scrollDir = "";
var f;
var scrolling;
function setIframeVar() { //Or whatever you wanna call it
f = top.frames['slider']; // Your IFrame
}

<body onLoad="setIframeVar()">
Or you can leave it as is and just move the scripting below the IFRAME source someplace.

Ultragames
08-29-2002, 11:27 PM
only one more problem, I already have an onload. How do I do two onloads? THANK YOU for all you help bwt!

beetle
08-29-2002, 11:40 PM
Just separate with a semicolon

onLoad="function1(); function2();"

Ultragames
08-29-2002, 11:45 PM
PROBLEM! It scroll the entire window. Not the iframe I specified. . . But were almost there. (I think we can I think we can)

http://images01.gograph.com/Images-8712/AnimatedGif/smiley_gun01.gifhttp://images01.gograph.com/Images-8712/AnimatedGif/smiley_gun07.gif

Ultragames
08-30-2002, 12:03 AM
I fixed it!!! Thanks sooooooooooooooooooooooo much!:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum