PDA

View Full Version : Need some javascript assistance.


Thrash123
1st Jan 2004, 03:57 PM
Ok, I just started into Javascript. I have an older reference book that has been helping me with syntax, but I have a question. My searches on Google can't seem to answer this, so I'd though I would toss it out here since I have other things I need to do. I'm a C++ coder myself, so I don't need a Javascript primer, just help figuring out how to go about this.

Ok, lets say this... I have a table, 2 buttons, and an iframe in a cell in that table. the 2 buttons are outside the iframe. I want to disable the ordinary scrollbar, and have one button scroll the iframe down when clicked, and the other scroll up when clicked. I want it to work like the normal scroll buttons - when you hold down the button, it keeps scrolling. It'll stop, obviously, whenever you release the mouse button.

Alternatively, I could go with the mouseover scrolling like @ www.sonicmayhem.com - however I don't like mouseover scrolling.

So, gimme some code. If you could comment it for me I'd appreciate it, but it's not necessary since I already have a decent knowledge when it comes to the commands in Javascript pretty well (and have a decent resource at my disposal). I'll give you credit in the source code for whoever helps a reasonable amount ;)

*update, after the below 2 posts because I didn't want to feel guilty about bumping it again :)*

Ok, here is the source code of the concept for the scroller. When the Scroller function is called, it is passed a number (which determines the direction). When the mouse button is released, it will try to break the loop. However, I get an infinite loop (lockup) whenever I click on one of the buttons - presumeably because it's not capturing the mouseup event. I'm stumped. This is my first javascript stuff though :)


var Counter = 0;

window.captureEvents(Event.MOUSEUP);

function handle(evnt)
{
Counter = 123;
return true;
}

function Scroller(intDir)
{
while(Counter == 0)
{
if (intDir == 1)
mainiframe.scrollBy(0,-10);
else
mainiframe.scrollBy(0,10);
}
}

Thrash123
1st Jan 2004, 06:25 PM
You can see what I have done so far here. The only thing I can't figure out is how to get it to continue to scroll while I hold down the mouse button (Note: That content is test content - that isn't going to be the layout inside the page at all).

http://members.peoplestar.net/dcp@peoplestar.net/

I was also trying to make headway on my date & time header, but I can't get it to work either. If someone could debug that for me I'd appreciate it :)

*edit*

FUDGEMONKGER. JUDASMONKIES.

Tripod breaks the scoller buttons in Moz FB 0.6.1 - Whenever you click one, it thinks you are leaving a tripod webpage - so it gives you a nice popup. Well, that breaks the scollers! It works in IE, and it works when opened from my HDD, so I'm thinking it has to be tripod. I'm going to try it in some of my banner and popup free webspace... GAH.

*edit again*

Uploaded to other webspace, check above URL again.

Thrash123
1st Jan 2004, 09:31 PM
Ok, nevermind on the header fix, I got it all working now. I just need to figure out what I am going to do about the scroller schtuff.